First time I click, nothing. Second time, the first alert fires twice. Third time, the second alert fires twice, and the first one fires once. Fourth time, it gets even weirder. I guess I’m using toggle() wrong, but I don’t see how. The code is
<button onclick="$(this).toggle(function(){alert(1)}, function(){alert(2)})">Play</button>
Fiddle: http://jsfiddle.net/2uRKD/
Thanks!
Toggle is a jquery event which toggles between alternative clicks and you do not need click event to bind to toggle.
Live Demo