Side navigation
#4047 closed bug (worksforme)
Opened February 02, 2009 10:12PM UTC
Closed February 03, 2009 02:02AM UTC
Last modified February 03, 2009 10:44PM UTC
Selector, <select> and val() returns inconsistent value
Reported by: | nminale | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.3.2 |
Component: | unfiled | Version: | 1.3.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Hi,
I have the following code,
<div id="testDiv">
<select id="testSelect">
<option value="1">One</option>
<option value="2">Two</option>
</select>
<input type="button" id="testBtn" value="Test">
</div>
On the page, when I select "Two" from the drop down list and use JQuery to get the value of <select>, the result is inconsistent.
A. $("div[id='testDiv'] select[id='testSelect']").val(), it returns "1".
B. $("#testDiv").find("#testSelect").val(), it returns "1".
C. $("#testSelect").val(), it returns "2".
Using Firebug, I saw the selectors from A and B actually return all <option> elements... So naturally, it picks the value of the first option..
With JQuery 1.2.6, A, B and C return same value.
Please advise.
Thank you.
Attachments (1)
Change History (2)
Changed February 03, 2009 02:02AM UTC by comment:1
resolution: | → worksforme |
---|---|
status: | new → closed |
Changed February 03, 2009 10:44PM UTC by comment:2
Thanks for checking.
I found out that it was because a plug-in that I used, jquery.validation.js -- it's not compatible with JQuery 1.3.1.
After I upgraded this plugin to its latest version (1.5.1), everything works as expected.
I've attached a complete test case that seems to work fine for me. You mentioned Firebug so I assume you tested in Firefox, but If I've misinterpreted the problem, please reopen and attach a test case that demonstrates the problem.