Side navigation
#5452 closed bug (fixed)
Opened November 05, 2009 03:39AM UTC
Closed November 14, 2010 04:05AM UTC
$('#select_element_id').val("") bug when its option has no value attribute in ie6/ie7
Reported by: | Luckydog | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | 1.4 |
Component: | core | Version: | 1.3.2 |
Keywords: | select val ie6 ie7 | Cc: | |
Blocked by: | Blocking: |
Description
In ie6/ie7, if option element has no value attribute, option_element.value property will return an empty string. And when I set an ampty string value to a select using $('#select_element_id').val(""), jquery will selected the last option of the select element. This bug occurs in line 471 in the source code of jquery-1.3.2.js.
Here is some sample code cause the bug.
<select id="select_element_id">
<option value="">ALL</option>
<option>Name1</option>
<option>Name2</option>
<option>Name3</option>
</select>
$('#select_element_id').val("");
Attachments (1)
Change History (3)
Changed November 05, 2009 05:46PM UTC by comment:1
need: | Test Case → Patch |
---|
Changed January 08, 2010 01:09PM UTC by comment:2
The same problem exists in IE8 with .val(0) as in $('#select_element_id').val(0) when trying to reset the selected index value to 0.
Changed November 14, 2010 04:05AM UTC by comment:3
resolution: | → fixed |
---|---|
status: | new → closed |
http://jsfiddle.net/dmethvin/wmhB5/
Seems to be working in 1.4.4
Confirmed; test case attached with slightly different conditions. I think the code in .val() is there both because IE6 doesn't support select.value and because multiple browsers don't handle select multiple properly if you use select.value.