I have an HTML button to which I attach an event, using jQuery\'s bind(), like so:
$(\'#mybutton\').bind(\'click\', myFirstHandlerFunction);
Update: Since this form of
toggle()was removed in jQuery 1.9, the solution below does not work anymore. See this question for alternatives.
It looks like toggle() would solve your problem:
$("#mybutton").toggle(myFirstHandlerFunction, mySecondHandlerFunction);
The code above will register myFirstHandlerFunction and mySecondHandlerFunction to be called on alternate clicks.