求解<!doctype html><html><head><meta charset="utf-8"><title>京東輪播圖代碼</title></head><body><div class="slider" id="circle" ?style="width:790px; height:340px; overflow:hidden;"><a ><img src="images/zp (1).jpg" alt="" /></a><a ><img src="images/zp (2).jpg" styly="width:790px; height:340px" alt="" /></a><ul class="circle"><!--移動鼠標觸發(fā)事件--><li onmouseover="lunbo(1)" id="1" >1</li><li onmouseover="lunbo(2)" id="2">2</li></ul><div class="arrow"><a href="javaScript:;" class="arrow-l" onclick="bo2()" id="bo1"></a><a href="javaScript:;" class="arrow-r" onclick="bo1()" id="bo2"></a></div></div><script>? ? var a = 1;? ? var t = 0;? ? window.onload = function(){? ? t = setInterval("bo1()", 2000);? ? }function lunbo(num){a = num;var btn = document.getElementById("circle").getElementsByTagName("img")[0];for (var i=1;i<3;i++) {var li = document.getElementById("circle").getElementsByTagName("li")[i-1];li.style.backgroundColor = "#3E3E3E";?if(num == i){btn.src = "img/"+i+"p.jpg";li.style.backgroundColor = "#B61B1F";}}?}function bo1(){if(a==2){a = 1;}a++;lunbo(a);}function bo2(){if(a ==1){a = 2;}a--;lunbo(a);}</script></body></html>
代碼只輪播了一次
qq_許一_0
2017-05-02 11:14:12