标签:插入代码 info keyword else lis div function text color
<!DOCTYPE HTML> <html> <head> <meta charset=UTF-8> <meta name="keywords" content="白菜编辑部"> <title>白菜编辑部</title> <style type="text/css"> </style> <script type="text/javascript" src="jquery-1.8.0.min.js"></script> <script type="text/javascript"> jQuery (function ($) { var p = $ (‘div.icList>ul.aaa‘); var array = p.children (‘li‘); array.sort (function () { var rand = Math.random (); if (rand > 0.5) { return 1; } else { return -1; } }); array.each (function (i, dom) { p.append ($ (this)); }); }); </script> </head> <body> <div class="icList"> <ul class="aaa"> <li>111111</li> <li>222222</li> <li>333333</li> <li>444444</li> <li>555555</li> <li>666666</li> </ul> </div> </body> </html>
还有一种方法没试过也分享下
$(".aaa li").each(function(){
if(parseInt(Math.random()*2)==0){
$(this).prependTo($(this).parent());
}
});
标签:插入代码 info keyword else lis div function text color
原文地址:https://www.cnblogs.com/li-sir/p/10557626.html