Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#11991 closed bug (duplicate)

jQuery .click() behaves different that browser .click() and human click

Reported by: ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com ) Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

Hi again guys.

I found .click() is behaving in a strange way so I'll post it here, before all sorry if it's not a bug and it's documented anywhere.

When I assign a "click" handler to a input type=checkbox, normally when the event fires the checkbox is already checked or unchecked, so I can use $(this).is(":checked") to know about the new state. When I say normally, I refer to human click, clicking on a <label for="id"> which points to the checkbox, or document.getElementById("id").click(). But if I do $("#id").click(), the event fires before the checkbox gets checked/unchecked, so I can´t handle the event consistently.

You can see it there: http://jsfiddle.net/s3Jsk/3/

Tested on IE7, 8, FF13 & Chrome 19, wrong behavior everywhere.

I'm thinking about merging it with http://bugs.jquery.com/ticket/11983, which also behaves different with browser click and jQuery click;

Best regards.

Change History (4)

comment:1 Changed 7 years ago by ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com )

Sorry guys, changes on http://bugs.jquery.com/ticket/11983#comment:2, finally both tickets are not related.

So think about this ticket individually.

comment:2 Changed 7 years ago by dmethvin

Resolution: duplicate
Status: newclosed

comment:3 Changed 7 years ago by dmethvin

Duplicate of #3827.

comment:4 Changed 7 years ago by ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com )

I'm happy to see that ticket http://bugs.jquery.com/ticket/3827 has been tagged as "1.9-discuss". Congratulations in always keep efforting to make the best decissions about the issues - I understand the arguments to set that problem as wontfix aswell as the imporance of making jquery behavior consistent in all the situations. Best regards.

Note: See TracTickets for help on using tickets.