javascript - How to repeatedly sort element in div without losing clickability? -


example of need:

http://jsfiddle.net/bbgmb/1/

var interval = 100; $(function(){     $('#container').children().click(function(e){         alert($(e.target).text()+" clicked");     });     setinterval(function(){         $('#container').children().sort(function(a,b){             if($(a).text() > $(b).text()) return 1;             if($(a).text() < $(b).text()) return -1;             return 0;         }).appendto('#container');     },interval); }) 

if change interval 10000 works fine.

but need interval 100 or lower.

modified fiddle compare. please check http://jsfiddle.net/bbgmb/4/

var interval = 100; $(function(){     $('#container').children().click(function(e){         alert($(e.target).text()+" clicked");     });     setinterval(function(){         var origc = $('#container').children();          var newc  = $.extend([], origc);              newc.sort(function(a,b) {             if($(a).text() > $(b).text()) return 1;             if($(a).text() < $(b).text()) return -1;             return 0;         });         (var i=0; < origc.length; i++) {             if (origc[i] !== newc[i]) {                 newc.appendto('#container');                 break;             }         }      },interval); }) 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -