Bug Tracker

Modify

Ticket #9071 (closed bug: fixed)

Opened 3 years ago

Last modified 2 years ago

$('<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
Blocking: Blocked by:

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.

Change History

comment:1 Changed 3 years ago by rwaldron

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

Confirmed. cc'ing timmywil

comment:2 Changed 3 years ago by timmywil

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

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

Changeset: 4ac2fdda2c26e9b64502b9ef50748427bed2f3c6

comment:3 Changed 3 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 3 years ago by timmywil

  • Priority changed from undecided to high
  • Milestone changed from 1.next to 1.6.1

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.