In jQuery, why does programmatically triggering 'click()' on a checkbox not immediately check it?

前端 未结 2 1495
情话喂你
情话喂你 2020-12-20 13:28

Update: This only applies to jQuery 1.8 and below. This was fixed in jQuery 1.9.

Here is my minimal jsfiddle example: http://jsfiddle.net/8fuEJ/. I\'m using

2条回答
  •  一生所求
    2020-12-20 14:32

    The click event fires before the default action. It does this to allow you to prevent the default action from occurring by returning false from the handler.

    In your example, this means that you alert the old value as the default action of changing the checkbox state has not yet occurred.

提交回复
热议问题