I'm using placeholders for text inputs which is working out just fine. 我正在使用占位符进行文本输入,效果很好。 But I'd like to use a placeholder for my selectboxes as well. 可是我也想为个人选择框使用一个占位符。 Of course I can just use this code: 固然,我能够使用如下代码: css
<select> <option value="">Select your option</option> <option value="hurr">Durr</option> </select>
But the 'Select your option' is in black instead of lightgrey. 可是“选择您的选项”是黑色而不是浅灰色。 So my solution could possibly be CSS-based. 所以,个人解决方案可能基于CSS。 jQuery is fine too. jQuery也很好。 ide
This only makes the option grey in the dropdown (so after clicking the arrow): 这只会使下拉菜单中的选项变为灰色(所以,单击箭头后): this
option:first { color: #999; }
The question is: How do people create placeholders in selectboxes? 问题是:人们如何在选择框中建立占位符? But it has already been answered, cheers. 但它已经获得回答,欢呼。 spa
And using this results in the selected value always being grey (even after selecting a real option): 使用此方法会致使所选值始终为灰色(即便在选择实选项后): .net
select { color: #999; }