Javascript

Jquery 리스트 순서 랜덤 변경

withWalker™ 2017. 1. 11. 23:31

리스트 순서 랜덤 변경

 

 

function() {
  $('ul').each(function() {
    var ul = $(this);
    
    var liArr = ul.children('li');
    
    liArr.sort(function() {
      var temp = parseInt(Math.random()*len);
      var temp1 = parseInt(Math.random()*len);
      return temp1-temp;
    }).appendTo(ul);
  });
});

 

 

See the Pen apdrzB by Kiyeol Yoo (@spiegel) on CodePen.

 

 

 

반응형