Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#9094 closed bug (fixed)

Issue with jQuery 1.6: Can't uncheck checkboxes

Reported by: Bertrand Marron <me@…> Owned by: Timmy Willison
Priority: high Milestone: 1.6.1
Component: attributes Version: 1.6
Keywords: Cc:
Blocked by: Blocking:

Description

Removing the checked attribute, or setting it to false, used to uncheck checkboxes in previous versions of jQuery.

jQuery 1.6 doesn't let you.

See http://jsfiddle.net/XwmGD/.

--
Bertrand Marron

Change History (9)

comment:1 Changed 12 years ago by Timmy Willison

Component: unfiledattributes
Owner: set to Timmy Willison
Priority: undecidedhigh
Status: newassigned

jQuery 1.6 removes the ambiguity between attributes and properties. The checked attribute (by spec) only sets the default value. There is no checked attribute on that checkbox to remove. You need to set the checked property to false: .prop('checked', false) or .checked = false. We understand this will break some people's code so this will be changed to how it worked previously for 1.6.1.

comment:2 Changed 12 years ago by Timmy Willison

Resolution: fixed
Status: assignedclosed

Set corresponding property to false when removing boolean attributes. Fixes #9094

Changeset: 480b88ca37fb3aff4ba043298a8fb419905d3f21

comment:3 Changed 12 years ago by Timmy Willison

Milestone: 1.next1.6.1

comment:4 Changed 12 years ago by crescentfresh

Although this bug report only addresses boolean false, it should be noted that .attr('foo', true) is also broken. See http://jsfiddle.net/YsvyP/

comment:5 Changed 12 years ago by crescentfresh

Reported the boolean true case as a separate bug: #9103

comment:6 Changed 12 years ago by Timmy Willison

#9127 is a duplicate of this ticket.

comment:7 Changed 12 years ago by mc

1.6 version seems to have bug on uncheck checkboxes. The following code works in 1.4.3, but not 1.6. Any idea? $('input:checkbox').attr('checked', false);

comment:8 Changed 12 years ago by Timmy Willison

@mc: You can use prop to set the property, which is what you are really after. $('input:checkbox').prop('checked',false);

comment:9 Changed 12 years ago by anonymous

Thanks a lot. Timmywil. "prop" works fine with 1.6 version in IE8.

Note: See TracTickets for help on using tickets.