Ticket #9404 (closed bug: invalid)
$.each() returns the value with strange behavior
| Reported by: | edk2pang@… | Owned by: | edk2pang@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | unfiled | Version: | 1.6.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
<select class="cmbField" name="test">
<option>- Choose -</option>
<option value="PTAXNO">TAX </option>
<option value="PTBANK_CODE">BANK NAME</option>
<option value="PTBANK_NO">ACCOUNT NUM</option>
<option value="PTBANK_NO_NAME">HOLDER</option>
</select>
$('.cmbField').each(function(idx, val) {
console.debug($(val).val());
});
--- OUTPUT (val returns textnode) ---
- Choose -
PTAXNO PTBANK_CODE PTBANK_NO PTBANK_NO_NAME
<select class="cmbField" name="test">
<option value="">- Choose -</option>
<option value="PTAXNO">TAX </option>
<option value="PTBANK_CODE">BANK NAME</option>
<option value="PTBANK_NO">ACCOUNT NUM</option>
<option value="PTBANK_NO_NAME">HOLDER</option>
</select>
$('.cmbField').each(function(idx, val) {
console.debug($(val).val());
});
--- OUTPUT--- (IF it has empty string value with attribute-> OK)
- empty string -
PTAXNO PTBANK_CODE PTBANK_NO PTBANK_NO_NAME
Change History
comment:2 Changed 2 years ago by rwaldron
- Owner set to edk2pang@…
- Status changed from new to pending
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. To get you started, I've created this boilerplate: http://jsfiddle.net/rwaldron/da3nM/ Open the link and click to "Fork" in the top menu.
comment:3 Changed 2 years ago by dmethvin
- Status changed from pending to closed
- Resolution set to invalid
http://www.w3.org/TR/html401/interact/forms.html#h-17.6
value = cdata [CS] This attribute specifies the initial value of the control. *If this attribute is not set, the initial value is set to the contents of the OPTION element.*
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

1st one
2nd one