Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#14349 closed bug (notabug)

Using .val() on select lists behaves differently in 1.9.1 than it does in 2.x

Reported by: Tony.Kaser@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.0.0
Keywords: Cc:
Blocked by: Blocking:

Description

I have a select list with multiple items in it. JQuery versions: 1.9.1 and JQuery 2.x Browsers: Firefox 22.0 and IE7-10 Operating System: Windows 7

I use $('#selectListId').val() to set the selected value to nothing. (Not my choice, but it exists throughout the code I have to support)

If I'm using version 1.9.1, my list shows as expected, nothing selected. If I'm using version 2.x, my list shows with a blank, nothing selected. My list is still there but there is a blank showing in the select box.

The jsfiddle is http://jsfiddle.net/CFszv/3/

Change History (2)

comment:1 Changed 6 years ago by timmywil

Resolution: notabug
Status: newclosed

1.x and 2.x edge versions are consistent. 1.9.1 actually has the incorrect behaviour. If no options match when setting the value on a select element, selectedIndex should get set to -1, which means it should be blank.

1.x: http://jsfiddle.net/CFszv/5/ 2.x: http://jsfiddle.net/CFszv/4/

comment:2 Changed 6 years ago by dmethvin

#14306 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.