How do i chain custom function after a delay has been set
here's what i mean: http://jsbin.com/uluyim
$(function(){
$('.container').hide();
$('.container').delay(2000).fadeIn().$(document).callMe();
function callMe () {
alert ("It works!");
}
});
Thanks!
Change line below
$('.container').delay(2000).fadeIn().$(document).callMe();
to
$('.container').delay(2000).fadeIn(callMe)
In your case, you can use arunes's solution, using the callback from the animation. However, if you need to add a delay between the animation and the callback that gets executed, you can do that too, as in:
$('.container').fadeIn(function () {
$(this).delay(2000).queue(function () {
alert('Custom function executed two seconds after fadeIn()!');
$(this).dequeue();
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With