<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
#container {
margin: 20px auto;
width: 1200px;
height: 800px;
}
.banner {
position: relative;
width: 1200px;
height: 220px;
}
li {
list-style: none;
position: absolute;
top: 0;
left: 0;
}
.none {
display: none;
}
</style>
</head>
<body>
<div id="container">
<ul class="banner">
<li><img src="pic1.png" alt=""></li>
<li><img src="pic2.png" alt=""></li>
</ul>
<input type="hidden" value="0" id="liIndex">
</div>
<script src="jquery-1.11.3.js"></script>
<script>
$.extend({
seI_autoFn: null,
loopLen: $(".banner li").length,
autoFn: function () {
var index = $("#liIndex").val();
if (index < $.loopLen - 1) {
index++;
} else {
index = 0;
}
$($(".banner li")).addClass("none");
$($(".banner li")).eq(index).fadeIn("slow", function () {
$(this).removeAttr("style").removeClass("none")
});
$("#liIndex").val(Number(index));
clearTimeout($.seI_autoFn);
$.seI_autoFn = setTimeout(function () {
$.autoFn()
}, 3000);
},
})
$.autoFn();
</script>
</body>
</html>