Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
38
rated 0 times [  44] [ 6]  / answers: 1 / hits: 29522  / 13 Years ago, tue, november 22, 2011, 12:00:00

Please take a look at the example: http://jsfiddle.net/HHDpK/1/



As you see the difference between two choosers is only the line



$(#chooser-1 .y).removeAttr(selected);


But as a result their states are different (especially in Chrome).
Am I missing anything, or it is a bug?


More From » jquery

 Answers
2

Looks like internal bug of jQuery with attributes.



Note that in older versions, before .prop() was introduced in 1.6 version, it works as expected.



In the newer versions, just use .prop() to deal with such properties of elements:



$(#chooser-1 .x).prop(selected, selected);
$(#chooser-1 .y).removeProp(selected);


jsFiddle update.



More than that - using .removeProp(selected) on the element selected previously with prop() will cause the original selection to return instead of having nothing selected - ideal behavior.


[#88971] Monday, November 21, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
makaylahh

Total Points: 128
Total Questions: 106
Total Answers: 97

Location: Tanzania
Member since Wed, Feb 24, 2021
3 Years ago
;