Hi all,
Is there a way I can call the second function in toggle(function(){},function(){})
Thanks in advance
Hi all,
Is there a way I can call the second function in toggle(function(){},function(){})
Thanks in advance
how about
toggle(function(){ callFunctionOne(); callFunctionTwo(); });
I suggest such solution:
toggle(function(){},secondFunction);
function secondFunction() {}
And now you can call it how you want :)
You could skip the toggle to the next function, if you really wanted to I suppose, for example:
$("div").toggle(function() {
alert("First");
}, function() {
alert("Second");
});
Then you can manually advance the .toggle()
function array (without calling the first function), like this:
$("div").data('lastToggle' + $("div").data().events.click[0].handler.guid, 1);
Then just click the element or $("div").click()
, etc, and it'll fire the second function.
You can give it a try here, note that this only works in jQuery 1.4+ and is really just to show it's possible. You should however either bind them in reverse order, or give the second argument a named function as the other answers suggest.