Skip to main content

Bug Tracker

Side navigation

#9071 closed bug (fixed)

Opened May 03, 2011 06:04PM UTC

Closed May 03, 2011 06:49PM UTC

Last modified March 13, 2012 01:48PM UTC

$('<option></option>').val('myValue') no longer sets value

Reported by: kkalitowski@gmail.com Owned by:
Priority: high Milestone: 1.6.1
Component: attributes Version: 1.6
Keywords: Cc: timmywil
Blocked by: Blocking:
Description

jQuery 1.6 is not setting the 'value' attribute of an <option> element when using the .val() function.

With the following code

$('<option />').val('48a1b555-4015-498d-ac91-78aab2872364')

jQuery 1.5.2 gives a result of

<option value=​"48a1b555-4015-498d-ac91-78aab2872364">​</option>​

jQuery 1.6 gives a result of

<option>​</option>​

A workaround for the issue is to use

$('<option />').attr('value', '48a1b555-4015-498d-ac91-78aab2872364')

This has been reproduced on IE7 and Chrome.

Attachments (0)
Change History (4)

Changed May 03, 2011 06:17PM UTC by rwaldron comment:1

cc: → timmywil
component: unfiledattributes
status: newopen

Confirmed. cc'ing timmywil

Changed May 03, 2011 06:49PM UTC by timmywil comment:2

resolution: → fixed
status: openclosed

Fix setting value attributes on option elements. Fixes #9071.

Changeset: 4ac2fdda2c26e9b64502b9ef50748427bed2f3c6

Changed May 10, 2011 06:28PM UTC by ljharb@gmail.com comment:3

Made this JSFiddle before realizing the ticket was fixed: http://jsfiddle.net/Fg8xL/1/

Will this fix make it into 1.6.1?

Changed May 10, 2011 06:54PM UTC by timmywil comment:4

milestone: 1.next1.6.1
priority: undecidedhigh