$(function() {
var length = $("#demo").children("li").length - 1;
$("#cont .right").on("click", function() {
var $Index = $("#demo").children("li.active").index();
if($Index == length) {
$Index = -1;
}
$("#demo").children().removeClass("active");
$("#demo").children("li:eq(" + ($Index + 1) + " )").addClass("active");
});
$("#cont .left").on("click", function() {
var $Index = $("#demo").children("li.active").index();
if($Index == 0) {
$Index = length+1;
}
$("#demo").children().removeClass("active");
$("#demo").children("li:eq(" + ($Index - 1) + " )").addClass("active");
});
});
$(function() {
var length = $("#demo").children("li").length - 1;
var fun = function() {
var $Index = $("#demo").children("li.active").index();
if($Index == length) {
$Index = -1;
}
$("#demo").children().removeClass("active");
$("#demo").children("li:eq(" + ($Index + 1) + " )").addClass("active");
};
var inter = setInterval(function() { fun() }, 5000);
$("#cont a").on("mousemove", function() {
window.clearInterval(inter); //关闭
}).on("mouseout", function() {
inter = setInterval(function() { fun() }, 5000); //重新开启
})
})
var length = $("#demo").children("li").length - 1;
$("#cont .right").on("click", function() {
var $Index = $("#demo").children("li.active").index();
if($Index == length) {
$Index = -1;
}
$("#demo").children().removeClass("active");
$("#demo").children("li:eq(" + ($Index + 1) + " )").addClass("active");
});
$("#cont .left").on("click", function() {
var $Index = $("#demo").children("li.active").index();
if($Index == 0) {
$Index = length+1;
}
$("#demo").children().removeClass("active");
$("#demo").children("li:eq(" + ($Index - 1) + " )").addClass("active");
});
});
$(function() {
var length = $("#demo").children("li").length - 1;
var fun = function() {
var $Index = $("#demo").children("li.active").index();
if($Index == length) {
$Index = -1;
}
$("#demo").children().removeClass("active");
$("#demo").children("li:eq(" + ($Index + 1) + " )").addClass("active");
};
var inter = setInterval(function() { fun() }, 5000);
$("#cont a").on("mousemove", function() {
window.clearInterval(inter); //关闭
}).on("mouseout", function() {
inter = setInterval(function() { fun() }, 5000); //重新开启
})
})
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货