开发者

Checkbox with toggle() breaking the checked/unchecked state

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜