4

I would like to repeat the chained events starting at .animate() from inside itself (indicated by 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
   });
})        

This 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();
      });
   });          
0

1 Answer 1

2

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...

Sign up to request clarification or add additional context in comments.

1 Comment

This is just about what I needed to do, it helped me to complete the function correctly. posted above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.