<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style>
.img1{
display:block;
}
.img2{
display: none;
}
.img3{
display: none;
}
</style>
<script type="text/javascript">
var index = 0;
function changeImg() {
index ++;
var a = document.getElementsByClassName("img-slice");
if (index >= a.length) {
index = 0;
}
for (let i = 0; i < a.length; i ++) {
a[i].style.display = "none";
}
a[index].style.display = "block";
}
setInterval(changeImg, 2000)
</script>
</head>
<body>
<div class="imgBox">
<img class="img-slice img1" src="../img/3.jpg" alt="1">
<img class="img-slice img2" src="../img/2.jpg" alt="2">
<img class="img-slice img3" src="../img/6.jpg" alt="3">
</div>
</body>
</html>
超级无敌简单的轮播图实现
最新推荐文章于 2024-08-17 13:31:03 发布