Bug Tracker

Opened 13 years ago

Closed 12 years ago

#5452 closed bug (fixed)

$('#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:


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>






Attachments (1)

test-5452.html (485 bytes) - added by dmethvin 13 years ago.
IE being stupid about option values

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by dmethvin

Attachment: test-5452.html added

IE being stupid about option values

comment:1 Changed 13 years ago by dmethvin

need: Test CasePatch

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.

comment:2 Changed 13 years ago by [email protected]

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.

comment:3 Changed 12 years ago by dmethvin

Resolution: fixed
Status: newclosed


Seems to be working in 1.4.4

Note: See TracTickets for help on using tickets.