<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Easy Slider</title>
<style>
* {
margin: 0;
padding: 0;
}
img {
border: none;
}
#slider {
overflow: hidden;
width: 220px;
height: 160px;
border: 3px solid #EEE;
padding: 1px;
margin: 60px auto 0;
}
#slider li {
position: relative;
left: 0;
top: 0;
list-style: none;
}
</style>
<script src="jquery.js"></script>
<script>
function slider(id) {
var fir = $(id + ' li:first');
fir.addClass("active");
$(id + ' li').not(':first').hide();
setInterval(function () {
var act = $(id + ' li.active');
if(act.next().val() != undefined) {
act.hide(0, function() {
act.next().show();
act.removeClass('active');
act.next().addClass('active');
});
} else {
act.hide(0, function() {
fir.show();
act.removeClass('active');
fir.addClass('active');
});
}
}, 2000);
}
$(document).ready(function() {
slider('#slider');
});
</script>
</head>
<body>
<ul id="slider">
<li><a href="./1"><img src="1.png" /></a></li>
<li><a href="./2"><img src="2.png" /></a></li>
<li><a href="./3"><img src="3.png" /></a></li>
<li><a href="./4"><img src="4.png" /></a></li>
</ul>
</body>
</html>