Bug Tracker

Opened 9 years ago

Closed 9 years ago

#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:
Blocked by: Blocking:

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 (3)

comment:1 Changed 9 years ago by edk2pang@…

1st one

- Choose - 
PTAXNO
PTBANK_CODE
PTBANK_NO
PTBANK_NO_NAME 

2nd one

- empty string - 
PTAXNO
PTBANK_CODE
PTBANK_NO
PTBANK_NO_NAME

comment:2 Changed 9 years ago by Rick Waldron

Owner: set to edk2pang@…
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. 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 9 years ago by dmethvin

Resolution: invalid
Status: pendingclosed

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.*

Note: See TracTickets for help on using tickets.