本文实例为大家分享了JS轮播图的具体代码,供大家参考,具体内容如下
right.onclick = function () {
//把所有人的opacity置为0
/for (var i = 0; i < img.length; i++) {
img[i].style.opacity = 0;
}/
img[index].style.opacity = 0;
img[index].style.zIndex = 0;
lilist[index].className = '';
// index++;
index == 7 ? index = 0 : index++;
lilist[index].className = 'on';
img[index].style.opacity = 1;
img[index].style.zIndex = 1;
};
left.onclick = function () {
img[index].style.opacity = 0;
lilist[index].className = '';
img[index].style.zIndex = 0;
// index--;
index == 0 ? index = 7 : index--;
lilist[index].className = 'on';
img[index].style.opacity = 1;
img[index].style.zIndex = 1;
};
for (var i = 0; i < lilist.length; i++) {
lilist[i].value = i;
lilist[i].onmouSEOver = function () {
var that = this;
timer=setTimeout(function () {
img[index].style.opacity = 0;
lilist[index].className = '';
img[index].style.zIndex = 0;
index = that.value;
lilist[index].className = 'on';
img[index].style.opacity = 1;
img[index].style.zIndex = 1;
},300)
};
lilist[i].onmouSEOut = function () {
clearTimeout(timer);
}
}
out.onclick = function (e) {
console.log(e.target);
};
timer1 = setInterval(right.onclick,2000);
out.onmouSEOver = function () {
clearInterval(timer1);
};
out.onmouSEOut = function () {
timer1 = setInterval(right.onclick,2000);
};
var num =5
var arr = [];
var img =document.images;
for(var i=0;i<img.length;i++){
if(i<5){
arr.push(img[i].offsetHeight);
}else {
img[i].style.position='abl'
}
}