Reputation: 14216
I am trying to get a function to fire once this animation is complete. is this possible with jquery?
Here is my code
$('html, body').animate({scrollTop:$("body > .addAccountForm1").offset().top }, 'slow');
I want to fire this after it is complete
$("body > .addAccountForm1").find(".acctSelectSchl").val(5);
Thanks in advance!!
Upvotes: 0
Views: 45
Reputation: 148
I think what you are trying to do is this:
$(document).ready(function(){
$('html, body').animate({scrollTop:$("body > .addAccountForm1").offset().top }, 'slow', function(){
$("body > .addAccountForm1").find(".acctSelectSchl").val(5);
});
})
Upvotes: 2
Reputation: 1681
Absolutely, the 4th argument of animate is the complete handler (this is where you would put your code, or a call to another function to execute on completion).
From the jQuery documentation: .animate( properties [, duration ] [, easing ] [, complete ] )
Please see http://api.jquery.com/animate/ for a list of examples and full documentation.
Upvotes: 0
Reputation: 2175
$("selector").animate({},1000,function(){ // your call back function });
$('html, body').animate({scrollTop:$("body > .addAccountForm1").offset().top }, 'slow',function(){
$("body > .addAccountForm1").find(".acctSelectSchl").val(5);
});
Upvotes: 0