methuselah
methuselah

Reputation: 13206

Set multiple objects to a setTimeout function

Is it possible to setTimeout to multiple objects so their events occur in exactly same timespan?

This is what I have so far, but it is returning me a syntax error:

setTimeout(function() { 
$('#post_confirm').fadeOut('slow');}, 
$('#chat').height($chatHeight_user);}, 
1000);

Upvotes: 0

Views: 76

Answers (2)

David
David

Reputation: 1889

Try this:

setTimeout(function() { 
  $('#post_confirm').fadeOut('slow'); 
  $('#chat').height($chatHeight_user); 
},1000);

Upvotes: 1

Yotam Omer
Yotam Omer

Reputation: 15356

You have a syntax error, use:

setTimeout(function() { 
    $('#post_confirm').fadeOut('slow'); // lose the }, here
    $('#chat').height($chatHeight_user);
}, 1000);

setTimeout() works like this:

setTimeout(callback,time)

So you can replace callback with a single anonymous function that has all the other code in it.

Upvotes: 3

Related Questions