jquery/javascript - running two functions from an onComplete property
I'm using a plugin which has a property "onComplete
".
So I set something like this "onComplete: completeHandler
"
And it runs the function defin开发者_如何学Ced in:
function completeHandler()
I just need an additional one line of code that I need to run, is there a way to say to run two functions? Or is my best way to write another function called "alternateCompleteHandler
" and at the end of that function call completeHandler()
?
This is what you're looking for:
onComplete: function(){
function1();
function2();
}
If you want two functions to be run simultaneously, Use this:
setTimeout(function1,1);
setTimeout(function2,1);
If you want them to run after each other, do this:
onComplete: function() {completeHandler();alternateCompleteHandler();}
its called anonymous function.
I would say the most flexible way is to create a new function. I think there are better options for naming it, though :)
精彩评论