Ticket #9927 (closed bug: invalid)
$("select").attr("disabled", ""); does not work anymore
| Reported by: | giovanni.g@… | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | attributes | Version: | 1.6.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
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".
regards
Change History
comment:1 Changed 22 months ago by addyosmani
- Priority changed from undecided to low
- Resolution set to invalid
- Status changed from new to closed
- Component changed from unfiled to attributes
comment:2 Changed 22 months ago by jquery@…
Why was this marked invalid?
From[BLOG » JQUERY 1.6.1 RELEASED| http://blog.jquery.com/2011/05/12/jquery-1-6-1-released/]:
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.
comment:3 Changed 22 months ago by dmethvin
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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: http://stackoverflow.com/questions/5874652/prop-vs-attr