【发布时间】:2014-10-14 03:51:58
【问题描述】:
这是一种按顺序添加的方法,但我可以弄清楚如何按随机顺序添加。
关于如何完成随机顺序的任何想法?这是我的小提琴:
$("li").each(function(i,el) {
var $this = $(this);
var random = Math.floor(Math.random() * $this.length);
setTimeout(function() {
$this.eq(random).addClass('active');
}, i*1000); // milliseconds
});
【问题讨论】: