Ticket #4998 (closed bug: invalid)
attr("selected", true) fails in IE6
|Reported by:||scottamain||Owned by:|
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