Side navigation
#4998 closed bug (invalid)
Opened August 01, 2009 12:30AM UTC
Closed August 02, 2009 08:17PM UTC
Last modified March 15, 2012 03:56PM UTC
attr("selected", true) fails in IE6
Reported by: | scottamain | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | core | Version: | 1.3.2 |
Keywords: | IE6, selected | Cc: | |
Blocked by: | Blocking: |
Description
In my script, I'm finding an <option> element and setting it to be selected.
The following code fails in IE6:
var selectedItem = $("#Control option[value='"+selectedLevel+"']");
selectedItem.attr("selected","true");
This code, however, works in IE6 (and all browsers):
var selectedItem = $("#Control option[value='"+selectedLevel+"']").get(0);
selectedItem.setAttribute('selected',true);
So the normal DOM function "setAttribute" is more successful than jQuery, which I suspect is using the (known-to-fail in IE6) "selected" field (as in, selectedItem.selected = true)... that fails in IE6 the same as my jquery sample above.
I'm using v1.3.2
Attachments (0)
Change History (1)
Changed August 02, 2009 08:17PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
You should be using:
That's always worked for me on all browsers. Since the option element has a selected property, it's used in preference to the html attribute when you try to set it with
.