相关疑难解决方法(0)

如何随机排序列表项?

我目前有这个代码随机排序列表项:

var $ul = $('#some-ul-id');
$('li', $ul).sort(function(){
   return ( Math.round( Math.random() ) - 0.5 )
}).appendTo($ul);
Run Code Online (Sandbox Code Playgroud)

但是,有没有更好的解决方案呢?

javascript sorting random jquery html-lists

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

html-lists ×1

javascript ×1

jquery ×1

random ×1

sorting ×1