Jump to content

jQuery event queuing.


afish674

Recommended Posts

I am trying to make it, so that when I click on the h2 element the background opacity will fade to 25% and get a margin of 20px. Then when this is complete, fade the element with the class "speech" to 50% opacity. However at the moment everything is happening at the same time and I can't work it out. Is this something to do with more than one element being targeted by the click? Do I need to use the queue() method? My code is:

$('h2').click(function(){  $(this)   .fadeTo('slow', '0.25')   .animate({marginLeft:'20px'}, {duration:'slow', queue: false});   $('div.speech').fadeTo('slow', '0.5');  });

Thanks!

Link to comment
Share on other sites

 $('h2').click(function(){  $(this)   .fadeTo('slow', '0.25')   .animate({marginLeft:'20px'},'slow', function(){   $('div.speech').fadeTo('slow', '0.5');	 });  });    

then function within the animate function is applied only when the margin animation is finished.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...