jquery - Using .fadeIn() sequentially -


i've got bunch of divs, default set display:none, fadein 1 one after delay of 500ms. approach below works great, way should be? happens if there no more div value of display:none?

function myfadein() {     $(".myitems:hidden:first").fadein(500, function(){ myfadein(); }); }  ("#mybutton").click(function(){     myfadein(); }); 

i made few little changes, in part make function more generic, otherwise code should work.

function recursivefadein(selector) {     $(selector+":hidden").eq(0).fadein(400, function(){          recursivefadein(selector);      }); }  $("#mybutton").on("click",function(e){     recursivefadein("ul > li"); }); 

here jsfiddle: http://jsfiddle.net/qnabc/1/

i replaced ":first" selector eq(0) performance (see jquery :first vs. .first()), , there many other little rtweaks can if you're crazy performance (see performance of jquery visible).


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -