Modify ↓
Ticket #4392 (closed bug: invalid)
.val('') does not deselect
| Reported by: | cdude | Owned by: | |
|---|---|---|---|
| Priority: | trivial | Milestone: | 1.4 |
| Component: | unfiled | Version: | 1.3.2 |
| Keywords: | select | Cc: | |
| Blocking: | Blocked by: |
Description
To clear a form I set "myform" attributes and use
$([myform]).val("").
This does not work for selects. The code tries something like this:
option.selected = (option.value == "");
(or something similar). Actually,
option.selected = false;
does not do anything in IE! It would work as expected if
select.selectedIndex = -1;
came first.
BTW, I can't find the "select" selector in your online docs.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Can you attach a test case that shows exactly what the code does?
Where does the option variable come from?
The "select" selector is $("select") since it's the name of the HTML element.