jq点击事件为什么只执行一次
<script>varlist=$("#content").children();varlistt=$("#content").children().find('span...
<script>
var list = $("#content").children();
var listt = $("#content").children().find('span');
var len = list.length;
var index = 0;
var interval = null;
$("#begin").on('click',type);
function type() {
if(this.running) return;
this.running = true;
this.remain = 5000 + Math.random() * 1000;
interval = setInterval(function() {
if(begin.remain < 500) {
clearInterval(interval);
} else {
listt[index].className = "";
list[index].className = "";
list[(index + 1) % len].className = "current";
listt[(index + 1) % len].className = "span";
index = ++index % len;
begin.remain -= 100;
}
}, 100)
}
</script> 展开
var list = $("#content").children();
var listt = $("#content").children().find('span');
var len = list.length;
var index = 0;
var interval = null;
$("#begin").on('click',type);
function type() {
if(this.running) return;
this.running = true;
this.remain = 5000 + Math.random() * 1000;
interval = setInterval(function() {
if(begin.remain < 500) {
clearInterval(interval);
} else {
listt[index].className = "";
list[index].className = "";
list[(index + 1) % len].className = "current";
listt[(index + 1) % len].className = "span";
index = ++index % len;
begin.remain -= 100;
}
}, 100)
}
</script> 展开
1个回答
2017-01-17
展开全部
你也可以做个死循环
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询