jquery - shuffling `li` elements within a `ul` -
jquery - shuffling `li` elements within a `ul` -
i want shuffle li elements within ul - , found this working code. don't understand how replacing elements 'in place' instead of adding them end of existing array.
var list = $('ul'); var count = $('ul li').length; (var = 1; < count; i++) { var j = math.floor(math.random() * count); $('li', list).eq(j).appendto(list); } what behavior of .eq() or .appendto() overlooking in docs makes possible? thanks!
jquery
Comments
Post a Comment