Scott Paterson
Scott Paterson

Reputation: 141

this.defaultValue returns undefined for select element

Normal HTML dropdown menu:

<select name="email" id="email">
     <option value="2" selected="selected">Before redirecting to PayPal</option>
     <option value="1">After payment is successful</option>
     <option value="3">Never send email</option>
</select>

Using jQuery this.defaultValue returns 'undefined'.

Using $(this).val() returns '2', correctly.

Why is this.defaultValue returning 'undefined'?

Upvotes: 0

Views: 225

Answers (1)

Artur Filipiak
Artur Filipiak

Reputation: 9157

As described on W3C, defaultValue works only with certain types of the elements

defaultValue of type DOMString
When the type attribute of the element has the value "text", "file" or "password" (...)

Upvotes: 4

Related Questions