Skip to main content

Bug Tracker

Side navigation

#9927 closed bug (invalid)

Opened July 28, 2011 04:03AM UTC

Closed July 28, 2011 10:49AM UTC

Last modified March 09, 2012 05:58PM UTC

$("select").attr("disabled", ""); does not work anymore

Reported by: Owned by:
Priority: low Milestone: None
Component: attributes Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:

greetings, i upgraded from JQuery 1.4 to 1.6 and i noticed a change in behaviour of $foo.attr("disabled", "");

before it was working, now i had to replace it with $foo.removeAttr("disabled"), anyway i don't see any good explanation for this "new behaviour".


Attachments (0)
Change History (7)

Changed July 28, 2011 10:49AM UTC by addyosmani comment:1

component: unfiledattributes
priority: undecidedlow
resolution: → invalid
status: newclosed

Thanks for submitting a ticket!. In jQuery 1.6, a significant change was made to the way we handle getters and setters for attributes and as a part of this we introduced the idea of .prop() for accessing properties.

If you are using jQuery < 1.6 do this:

$foo.attr("disabled", value);

If you are using jQuery 1.6+:

$foo.prop("disabled", value); (eg. where value is true)

If you require more information about the differences between .prop() and .attr() you may find the following stackoverflow post useful:

Changed August 11, 2011 08:17PM UTC by comment:2

Why was this marked invalid?


''Specifically, boolean attributes such as checked, selected, readonly, and disabled in 1.6.1 will be treated just as they used to be treated in jQuery versions prior to 1.6.''

It seems the blog is saying one thing and you are saying something completely different. I understand the "preferred" or "desired" methods, but at the same time, if the blog says "this will work the way it always has", well, then, I sort of expect it to.....will work the way it always has.

Changed August 15, 2011 08:36PM UTC by dmethvin comment:3

If the caller had used true or false then it would work, since that's the way many people used to do it -- treating the attribute like a property. The use of a boolean value is a clue that they want the old behavior, since only strings are valid attribute values.

Changed August 15, 2011 08:37PM UTC by dmethvin comment:4

#10056 is a duplicate of this ticket.

Changed August 18, 2011 06:28AM UTC by addyosmani comment:5

#10073 is a duplicate of this ticket.

Changed October 05, 2011 06:42PM UTC by rwaldron comment:6

#10430 is a duplicate of this ticket.

Changed October 05, 2011 06:43PM UTC by rwaldron comment:7

#10109 is a duplicate of this ticket.