Call function inside .each ()

I would like to repeat chained events starting with .animate() from within myself (indicated by a comment). What is the correct way to write this?

 $("div").each(function(i, e){ $(this).animate({ left: $(this).parent().width() }, d[i], "linear", function(){ $(this).css({left: -parseInt($(this).css("width")) }) //would like to call function at this stage }); }) 

It ended up working:

  $("div").each( v = function(i, e){ $(this).animate({ left: $(this).parent().width() }, d[i], "linear", function(){ $(this).css({left: -parseInt($(this).css("width")) }) v(); }); }); 
+4
source share
1 answer

Like this?

 $("div").each(function(i, e){ $(this).animate({ left: $(this).parent().width() }, d[i], "linear", v = function(i){ $(this).css({left: -parseInt($(this).css("width")) }) if(i == null) v(1); }); }) 

Not sure I fully understood your goal ...

+2
source

All Articles