Click here to Skip to main content
14,733,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello coders
My first week of using jquery, going well so far but met my first small hurdle.
I would like the div animation to finish before triggering the next function.
From what I have read I need to add a function after animate but when I try and adapt the code I end up with errors. I hope someone can solve this one for me. Thanks :)

$(document).ready(function() {
$('#slick2').click(function() {
Updated 8-Jun-10 7:26am

You should use callback that will be called by jquery when the animation is complete:
$("#flash").animate({'width':'500px','height':'800px'},800, function() {
  // your code here: 
Thanks for the fix Dmitry. It worked great.
I have made some alterations to my code. I am now triggering the javascript from a button inside a swf and have added another function 'scrollToTop'(last one honest) At the moment I have this...

function scrollToTop(){
$.scrollTo('0px', 600 );
var wait = setInterval(function() {
	if( !$("#element1").is(":animated") ) {
}, 200);

It works but looks messy to me, the downside is that '#flash animate' and 'main' are triggering at the same time. I would prefer the three functions to fire sequentially. Many Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900