Ticket #9272 (closed bug: invalid)
Select component and attr("selected")
| Reported by: | jeflbtest@… | Owned by: | jeflbtest@… |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | attributes | Version: | 1.6.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Hello,
Since jQuery 1.6 and 1.6.1, I'm trying to make working my intranet site, but it's hard to make it compatible with IE6 and IE>6 , OPERA.
My problem was to select dynamics values after charging data.
This was ok in 1.5.2 but not anyway since >1.6
I tried to use prop() function with :
$("#myList").find("option[value=\"" + myConf.code + "\"]").attr("selected",true) but not ok with IE6!
IE 6 must have "true" (double quoted) value instead of true ! This value "true" isn't compatible with OPERA
The only way I found, to make it compatible in my code, I added :
if(isIE6) {
valSelected = "true";
} else {
valSelected = "selected";
}
.....
$("#myList").find("option[value=\"" + myConf.code + "\"]").attr("selected",valSelected );
AND
mySeletedValue = $("#myList").find("option[selected=" + valSelected + "]").attr("value");
I hope this code could help somebody.
Jeff.
Change History
comment:1 Changed 2 years ago by addyosmani
- Owner set to jeflbtest@…
- Priority changed from undecided to low
- Status changed from new to pending
- Component changed from unfiled to attributes
comment:2 follow-up: ↓ 3 Changed 2 years ago by ajpiano
FWIW, the recommended way to set an option in a select to be selected if you know its value is to use the .val() method directly on the select itself. For instance:
$("#myList").val(myConf.code);
comment:3 in reply to: ↑ 2 Changed 2 years ago by jeflbtest@…
- Status changed from pending to new
Replying to ajpiano:
FWIW, the recommended way to set an option in a select to be selected if you know its value is to use the .val() method directly on the select itself. For instance:
$("#myList").val(myConf.code);
Thanks for this but it's what I done before 1.6.1, this code doesnt work in IE6.
It throws an IE6 exception : Impossible to set selected property....
comment:5 Changed 2 years ago by trac-o-bot
- Status changed from pending to closed
- Resolution set to invalid
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsFiddle.net that reproduces the issue experienced to help us assess your ticket!
Additionally, test against the jQuery (edge) version to ensure the issue still exists.