Bug Tracker

Opened 11 years ago

Closed 10 years ago

#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:
Blocked by: Blocking:

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 (2)

comment:1 Changed 11 years ago by dmethvin

The code tries something like this

Can you attach a test case that shows exactly what the code does?

Actually, option.selected = false; does not do anything in IE!

Where does the option variable come from?

BTW, I can't find the "select" selector in your online docs.

The "select" selector is $("select") since it's the name of the HTML element.

comment:2 Changed 10 years ago by dmethvin

Resolution: invalid
Status: newclosed

Closed-inactive.

Note: See TracTickets for help on using tickets.