在学习jq轮播图淡入淡出效果的时候,代码如下:
<script>
var index = 0;
var run = function () {
index++;
if (index > $("ul>li").length - 1) {
index = 0;
}
$("ul>li").eq(index).stop(true, true).fadeIn(300).siblings().fadeOut(300);
$("ol>li").eq(index).attr("style", "background:red").siblings().attr("style", "background:none");
}
var timer = setInterval(run, 3000);
$("div").hover(function () {
clearInterval(timer);
}, function () {
timer = setInterval(run, 3000);
})
// 分页器点击
$("ol>li").click(function () {
index = $(this).index();
$("ul>li").eq(index).stop(true, true).fadeIn(300).siblings().fadeOut(300);
$("ol>li").eq(index).attr