Skip to main content

Bug Tracker

Side navigation

#9404 closed bug (invalid)

Opened May 23, 2011 09:13AM UTC

Closed May 23, 2011 02:35PM UTC

$.each() returns the value with strange behavior

Reported by: edk2pang@gmail.com Owned by: edk2pang@gmail.com
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

Attachments (0)
Change History (3)

Changed May 23, 2011 09:19AM UTC by edk2pang@gmail.com comment:1

1st one

- Choose - 
PTAXNO
PTBANK_CODE
PTBANK_NO
PTBANK_NO_NAME 

2nd one

- empty string - 
PTAXNO
PTBANK_CODE
PTBANK_NO
PTBANK_NO_NAME

Changed May 23, 2011 01:27PM UTC by rwaldron comment:2

owner: → edk2pang@gmail.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. 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.

Changed May 23, 2011 02:35PM UTC by dmethvin comment:3

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