Bug Tracker

Modify

Ticket #9927 (closed bug: invalid)

Opened 3 years ago

Last modified 2 years ago

$("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 3 years 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

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

comment:2 Changed 3 years 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 3 years 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.

comment:4 Changed 3 years ago by dmethvin

#10056 is a duplicate of this ticket.

comment:5 Changed 3 years ago by addyosmani

#10073 is a duplicate of this ticket.

comment:6 Changed 3 years ago by rwaldron

#10430 is a duplicate of this ticket.

comment:7 Changed 3 years ago by rwaldron

#10109 is a duplicate of this ticket.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.