Side navigation
#9685 closed bug (duplicate)
Opened June 28, 2011 04:17PM UTC
Closed June 28, 2011 04:31PM UTC
Last modified March 14, 2012 02:56AM UTC
attr('selectedIndex') Not Working with FF in 1.6.2 RC1
Reported by: | sradoff@cfl.rr.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | attributes | Version: | 1.6.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
$(this).attr('selectedIndex') not working in FF where $(this) is a change event from a select control. Returns undefined. Works with IE6. Works OK with 1.5.1.
Attachments (0)
Change History (5)
Changed June 28, 2011 04:31PM UTC by comment:1
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
resolution: | → duplicate |
status: | new → closed |
Changed June 28, 2011 04:58PM UTC by comment:3
Why is the selectedIndex not an attribute? When I examine the javascript definitions it shows selectedIndex is a property of a select object. How come $(this).attr('selectedIndex') works in 1.5 but not in 1.6.2 RC1? If selectedIndex is not an attribute as claimed then how would one retrieve the selected index of a select control?
Changed June 28, 2011 05:37PM UTC by comment:4
Why is the selectedIndex not an attribute?
Because it is a *property*.
When I examine the javascript definitions it shows selectedIndex is a property of a select object.
Yes, you are correct, it is a property.
How come $(this).attr('selectedIndex') works in 1.5 but not in 1.6.2 RC1?
We fixed a bug.
If selectedIndex is not an attribute as claimed then how would one retrieve the selected index of a select control?
Use $(this).prop("selectedIndex")
or (even better) this.selectedIndex
which is probably more than 100 times faster to execute.
Changed June 28, 2011 05:39PM UTC by comment:5
@sradoff Sorry for the confusion. selectedIndex is a property and should never have been retrieved with attr, even though it admittedly did retrieve it. Since 1.6, jQuery has a function for retrieving native properties such as selectedIndex(http://api.jquery.com/prop), but in the past (and this continues to be true) selectedIndex could simply be retrieved with raw javascript:
this.selectedIndex
DaveMethvin ganked me, but I'll post anyway.
selectedIndex is not an attribute.