Possible Duplicate:
In jQuery, why does programmatically triggering ‘click()’ on a checkbox not immediately check it?
Update: This only applies to jQuery 1.8 and below. This was fixed in jQuery 1.9.
I have this checkbox.
<input type="checkbox" id="wtf">
And this event handler:
$('#wtf').click(function(ev) { ev.preventDefault(); alert(this.checked); });
When I click the checkbox, I first see the checkmark appear, then I see the alert "true", then I see the checkmark disappear.
But when I call $('#wtf').click()
, I don't see any checkmark appear, and I see the alert "false".
Why is the behavior different when the click is manual vs when the click is programmatic?
I'm using Google Chrome, if that makes a difference.