Having a placeholder in a Select option
This question already has an answer here:
I think this is what you want .
HTML:
<select id="choice">
<option value="0" selected="selected">Choose...</option>
<option value="1">Something</option>
<option value="2">Something else</option>
<option value="3">Another choice</option>
</select>
CSS :
#choice option { color: black; }
.empty { color: gray; }
JavaScript:
$("#choice").change(function () {
if($(this).val() == "0") $(this).addClass("empty");
else $(this).removeClass("empty")
});
$("#choice").change();
try this jsfiddle.
不知道这是你在找什么
<select>
<option value="" disabled selected>Select your option</option>
<option value="value1">Value 1</option>
<option value="value2">Value 2</option>
<option value="value3">Value 3</option>
</select>
链接地址: http://www.djcxy.com/p/70592.html
上一篇: 引导程序选择下拉列表占位符
下一篇: 在选择选项中有一个占位符