Skip to main content

Bug Tracker

Side navigation

#9926 closed bug (worksforme)

Opened July 28, 2011 02:29AM UTC

Closed July 28, 2011 11:02AM UTC

set value to select element

Reported by: gd_lzg@163.com Owned by: gd_lzg@163.com
Priority: low Milestone: None
Component: manipulation Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

code about below:

<select id="test">

<option value="13">11</option>

<option value="11">aa</option>

<select>

when i use $("#test").val("11") to set value to select element,the selected one is <option value="13">11</option>

but not <option value="11">aa</option>

Attachments (0)
Change History (3)

Changed July 28, 2011 02:30AM UTC by anonymous comment:1

my jquery version is 1.3.2

Changed July 28, 2011 02:42AM UTC by ajpiano comment:2

owner: → gd_lzg@163.com
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket! Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists - we do not solve bugs that exist only in jQuery 1.3.2 if they have since been addressed. To get you started, we've created this boilerplate: http://jsfiddle.net/rwaldron/da3nM/ Open the link and click to "Fork" in the top menu.

Changed July 28, 2011 11:02AM UTC by addyosmani comment:3

component: unfiledmanipulation
priority: undecidedlow
resolution: → worksforme
status: pendingclosed

I've put together a working test case based on the code you supplied here: http://jsfiddle.net/Gn2fF/1/. Please remember that the code you're using will set the selected option to the item with the *value* of 11, not the text '11'. To set the other item to be selected, simply use .val(13) in your test case instead. If you require further assistance with understanding the differences between setting selected elements based on option values or inline text values, please feel free to ask for assistance in the #jquery channel on freenode.