Skip to main content

Bug Tracker

Side navigation

#9094 closed bug (fixed)

Opened May 04, 2011 12:08PM UTC

Closed May 04, 2011 03:30PM UTC

Last modified March 08, 2012 06:43PM UTC

Issue with jQuery 1.6: Can't uncheck checkboxes

Reported by: Bertrand Marron <me@tusbar.net> Owned by: timmywil
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

Attachments (0)
Change History (9)

Changed May 04, 2011 02:46PM UTC by timmywil comment:1

component: unfiledattributes
owner: → timmywil
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.

Changed May 04, 2011 03:30PM UTC by timmywil comment:2

resolution: → fixed
status: assignedclosed

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

Changeset: 480b88ca37fb3aff4ba043298a8fb419905d3f21

Changed May 04, 2011 03:30PM UTC by timmywil comment:3

milestone: 1.next1.6.1

Changed May 04, 2011 05:52PM UTC by crescentfresh comment:4

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

Changed May 04, 2011 06:20PM UTC by crescentfresh comment:5

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

Changed May 05, 2011 04:57PM UTC by timmywil comment:6

#9127 is a duplicate of this ticket.

Changed May 05, 2011 09:56PM UTC by mc comment:7

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);

Changed May 05, 2011 10:35PM UTC by timmywil comment:8

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

Changed May 06, 2011 02:41PM UTC by anonymous comment:9

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