Reputation: 395
I have a jquery extended function that works perfectly but when i pass it through the setTimout it does not wait the the specified period and runs straight away.
jQuery(document).ready(function($) {
setTimeout($.mainmenuslider({
trigger:'close'
}),6000);
});
Any Ideas???
Upvotes: 5
Views: 5751
Reputation: 356
Try This!!
jQuery(document).ready(function($) {
setTimeout("$.mainmenuslider({
trigger:'close'
})",6000);
});
while using the setTimeout() , always try specifying the action need to be called in quotes.
Ex:
setTimeout("call_this_function()", 4000);
Upvotes: 2
Reputation: 630607
You need to pass an anonymous method to do what you want, like this:
jQuery(function($) {
setTimeout(function() {
$.mainmenuslider({
trigger:'close'
});
}, 6000);
});
Otherwise you're trying to pass the result of the function (making it execute immediately, and run nothing later).
Upvotes: 15
Reputation: 413996
You're calling the function right there when you're trying to set up the timeout to happen later. Instead:
jQuery(function($) {
setTimeout(function() {
$.mainmenuslider({trigger:'close'});
}, 6000);
});
Upvotes: 8