Bug Tracker

Modify

Ticket #4392 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

.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

comment:1 Changed 4 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 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

Closed-inactive.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.