Scott Paterson Scott Paterson - 1 year ago 52
HTML Question

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>

Using jQuery
returns 'undefined'.

returns '2', correctly.

Why is
returning 'undefined'?

Answer Source

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" (...)