Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#9071 closed bug (fixed)

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

Reported by: kkalitowski@… Owned by:
Priority: high Milestone: 1.6.1
Component: attributes Version: 1.6
Keywords: Cc: timmywil
Blocked by: Blocking:


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


A workaround for the issue is to use

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

This has been reproduced on IE7 and Chrome.

Change History (4)

comment:1 Changed 6 years ago by rwaldron

  • Cc timmywil added
  • Component changed from unfiled to attributes
  • Status changed from new to open

Confirmed. cc'ing timmywil

comment:2 Changed 6 years ago by timmywil

  • Resolution set to fixed
  • Status changed from open to closed

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

Changeset: 4ac2fdda2c26e9b64502b9ef50748427bed2f3c6

comment:3 Changed 6 years ago by ljharb@…

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

Will this fix make it into 1.6.1?

comment:4 Changed 6 years ago by timmywil

  • Milestone changed from 1.next to 1.6.1
  • Priority changed from undecided to high
Note: See TracTickets for help on using tickets.