Is it possible to change the state of a toggle function? Like:
myDiv.toggle … function 1 , function 2
- I click on the myDiv element, the function 1 executes
- I click again, function 2
- I click again, function 1
BUT - Change the state
- function 1 again
etc.
But I need to be able to change the state from outside the toggle function.
Here is a javascript object that uses closure to track it’s state and toggle:
Here is a jsfiddle that shows how to use it to toggle based with the following jquery: http://jsfiddle.net/yjPKH/5/