Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10827 closed bug (duplicate)

Triggering "click" event on a checkbox toggles the "checked" property after the handler function has run

Reported by: phistuck Owned by: phistuck
Priority: low Milestone: None
Component: event Version: 1.7.1rc1
Keywords: Cc:
Blocked by: Blocking:


When a user click on a checkbox with a click listener, it first flips the "checked" state and then fires the event. When a developer initiates a click on a checkbox with jQuery, it first fires the event and then flips the "checked" state.

A complete test case (for convenience, copy the code, type (without the quotes) within the location bar "data:text/html,", paste the code and press Enter) -

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
   function run()
    $("#test-checkbox").click(function () { alert(this.checked); });
    $("#test-click").click(function () { $("#test-checkbox").click(); });
 <body onload="run()">
  <input type="checkbox" id="test-checkbox"/>
  <span id="test-click">Initiate a click event</span>

This has been like that since forever (I checked with jQuery 1.2.4, 1.3.2, 1.4, 1.7, 1.7.1rc1).

Change History (3)

comment:1 Changed 11 years ago by timmywil

Component: unfiledevent
Owner: set to phistuck
Priority: undecidedlow
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

I believe the order is dependent on the browser. Which browser are you using?

comment:2 Changed 11 years ago by dmethvin

Resolution: duplicate
Status: pendingclosed

comment:3 Changed 11 years ago by dmethvin

Duplicate of #3827.

Note: See TracTickets for help on using tickets.