问题
In my select elements, I want a default text such as "please select an option". Also I use the jQuery plugin Validation with my form so that the user cannot submit the form if he has not selected something in my select elements.
Problem is, if I have "please select an option" in my selects, the form will validate.
How to deal with this problem?
回答1:
<select>
<option value="">Please select an option</option>
<option>
content is only used when the value
is not empty.
http://jsfiddle.net/s5AVg/
回答2:
<select>
<option style="display:none">please select an option</option>
<option disabled="disabled">I am a line</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
来源:https://stackoverflow.com/questions/16222655/how-to-create-a-select-placeholder