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

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -