Check box () that violates the checked / unchecked state

can anyone spread the light?

Why .toggle()does this violate the checked / unchecked state of the flag?

$('#checkbox').toggle(function(){},function(){});โ€‹

when I think he just does nothing.

crazy demonstration

this was taken from the comments of this answer

+3
source share
1 answer

toggle()called by two callbacks adds an event clickto the target element. The event will execute the first callback on clicks; the second - on the odd ones.

In addition, and therefore it changes behavior, according to the manual:

.preventDefault() , , , .toggle().

+4

All Articles