jQuery, wait for animation to end then do something

I have been using jQuery for quite some time now, following a question on one of the many forums and discussions group I visit daily I found that not many know that jQuery has a built in way to “listen” for an animation to end and then continue work.

For instance if I am using the slideDown effect, I can create a function that will only execute when the slide is finished.

how?

like this…

		$('div.menuOurHotel').slideDown("slow", function()
		{
			$("div.order_form").hide();
		});

This is a very useful way to create a responsive intuitive user interface.

Good luck

Avi Tzurel

My name is Avi Tzurel. I'm a professional web developer from Israel. I spend most of my day developing both web products and RIA applications as well as imparting my experience onto others. I speak, teach and write about my passions, and develop applications according to what I preach. I specialize in Flex, Adobe Air, HTML, XHTML, Javascript, jQuery and other Javascript libraries, on the server side I do .net along side with Ruby on Rails. You can connect with me on Twitter or email me through the contact page on this blog.

Posted Monday, July 12th, 2010 under General, JavaScript, jQuery.

Leave a Reply