#4047 closed bug (worksforme)
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.
- $("div[id='testDiv'] select[id='testSelect']").val(), it returns "1".
- $("#testDiv").find("#testSelect").val(), it returns "1".
- $("#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 (3)
Changed 15 years ago by
Attachment: | test-4047.html added |
---|
comment:1 Changed 15 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
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.
comment:2 Changed 15 years ago by
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.
Working example