Skip to main content

Bug Tracker

Side navigation

#14349 closed bug (notabug)

Opened September 10, 2013 04:44PM UTC

Closed September 10, 2013 07:22PM UTC

Last modified September 10, 2013 08:02PM UTC

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

Reported by: Tony.Kaser@McKesson.com 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/

Attachments (0)
Change History (2)

Changed September 10, 2013 07:22PM UTC by timmywil comment:1

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/

Changed September 10, 2013 08:02PM UTC by dmethvin comment:2

#14306 is a duplicate of this ticket.