Opened 11 years ago
Closed 11 years ago
#11564 closed bug (cantfix)
$('option').attr('selected', true) does not work on IE6
Reported by: | kanonji | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.1 |
Keywords: | ie6 select option | Cc: | |
Blocked by: | Blocking: |
Description
jQuery version
Error occurs
1.7.0 1.7.1 1.7.2
I tried
1.7.0 1.7.1 1.7.2
Browser
- Error occurs on IE6.
- No any errors on Chrome 18.0.1025.142
OS
- Windows XP
Test case
Description
If there are no option element when the html is loaded, $('option').attr('selected', true) does not work on IE6.
Step by step
Does not work
- Open IE6
- Select element with no option element like '<select></select>' on the html.
- Append/prepend some option elements with jQuery in the select element.
- attr('selected', true) for the option element appended step 3 above
- The error occurs.
work
- Open IE6
- Select element with some option elements.
- Do nothing or $('select').empty().
- Append/prepend some option elements with jQuery in the select element.
- attr('selected', true) for the option element appended step 4 above
- Work.
Change History (1)
comment:1 Changed 11 years ago by
Keywords: | ie6 select option added |
---|---|
Resolution: | → cantfix |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
The site jsdo.it does not work for me in IE6. This JSFiddle reproduces the issue:
http://jsfiddle.net/dmethvin/SVTUm/
This is a well-known issue with IE6 being unable to update options, and can be fixed with setTimeout or one of the solutions suggested in the links below:
http://jsfiddle.net/dmethvin/SVTUm/1/
Because it is a timing issue it can't be fixed within jQuery core without introducing even more issues (e.g., what if other things run before we select the option in the timeout?)
http://stackoverflow.com/questions/779379/why-does-settimeoutfn-0-sometimes-help
http://stackoverflow.com/questions/3737128/jquery-select-option-list-not-updated-fast-enough-in-ie6