tags:

views:

23

answers:

1

can anyone spread some light?

Why this .toggle() is breaking the checked/unchecked state of a checkbox?

$('#checkbox').toggle(function(){},function(){});​

when I think, it's just doing nothing.

crazy demo

this was taken from comments of this answer

+3  A: 

toggle() called with two callbacks adds a click event on the targeted element. The event will execute the first callback on even clicks; the second one on odd ones.

Also, and this is why it changes the behaviour, according to the manual:

The implementation also calls .preventDefault() on the event, so links will not be followed and buttons will not be clicked if .toggle() has been called on the element.

Pekka
ahhh got it! +1
Reigel