html
js
/*图片轮播*/ var but1 = document.getElementById("prev"); var abtn = document.getElementById("btn").getElementsByTagName("li"); //获取所有的按钮 var lis = document.getElementById('allImg').getElementsByTagName('li'); var but2 = document.getElementById("next"); var index = 0; var timer = null; but2.Onclick= function() { index++; if (index > lis.length - 1) { index = 0; } setImg(index); } but1.Onclick= function() { index--; if (index <0) { index = lis.length - 1; } setImg(index); } function changeImg() { if (index == lis.length - 1) { //当到最后一张图片时 index = 0 } else { index++; //图片索引发生改变 } setImg(index); } function setImg(index) { for (j = 0; j
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!