#13514 closed bug (fixed)
Setting "wrong" value of select-element using .val() is inconsistent in IE9 compared to other browsers
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.10/2.0 |
Component: | attributes | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Check this Fiddle: http://jsfiddle.net/ECFYX/9/
If the page has a select-element and the value for the select-element is changed using .val(xxx) but with a value that isn't found in the select-element's options then IE9 changes the select element to show an empty option, in all other browsers tested (IE8, IE10, FF, Chrome) it changes the selected value to be the first option.
Change History (8)
comment:1 Changed 10 years ago by
Component: | unfiled → attributes |
---|---|
Milestone: | None → 1.9.2 |
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 10 years ago by
Also checked that it doesn't help to set one of the select-element's options as selected, IE9 still changes the element to show an empty option.
comment:3 Changed 10 years ago by
Relevant discussion is at https://github.com/jquery/jquery/pull/1191
comment:4 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Fix #13514: Set selectedIndex to -1 when non-matching value is set on a select. Close gh-1191. (cherry picked from commit 48d71d0c3e53d1bb1688fc6c0593b008ced3403b)
Changeset: c9ca9bf509edd1dc0a92564210f3f325cc7555b6
comment:5 Changed 10 years ago by
Fix #13514: Set selectedIndex to -1 when non-matching value is set on a select. Close gh-1191.
Changeset: 48d71d0c3e53d1bb1688fc6c0593b008ced3403b
comment:8 Changed 10 years ago by
Seems like it is happening again on FF on a Mac. When setting $el.val(nonexistence) it creates an empty first option.
Although it seems like a bad idea to depend on this because HTML4 left it to the browser, the HTML5 spec did standardize the case:
Compare to the HTML4 language:
Looks like this was fixed in IE10.