Skip to main content

Bug Tracker

Side navigation

#11991 closed bug (duplicate)

Opened June 29, 2012 08:12AM UTC

Closed July 03, 2012 05:01PM UTC

Last modified July 04, 2012 07:10AM UTC

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.

Attachments (0)
Change History (4)

Changed June 29, 2012 09:24AM UTC by ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com ) comment:1

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

So think about this ticket individually.

Changed July 03, 2012 05:01PM UTC by dmethvin comment:2

resolution: → duplicate
status: newclosed

Changed July 03, 2012 05:01PM UTC by dmethvin comment:3

Duplicate of #3827.

Changed July 04, 2012 07:10AM UTC by ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com ) comment:4

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.