js代码IE9,11不兼容,轮播图不能轮播

zjn1456161412 2017-04-17 10:04:48
$(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); //重新开启
})

})
...全文
152 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjn1456161412 2017-04-17
  • 打赏
  • 举报
回复
来大神帮帮忙啊,IE8可以轮播,为什么IE9和11不行

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧