如何爲「選擇」框建立佔位符? - How do I make a placeholder for a 'select' box?

問題:

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;
}

解決方案:

參考一: https://stackoom.com/question/OM9z/如何爲-選擇-框建立佔位符
參考二: https://oldbug.net/q/OM9z/How-do-I-make-a-placeholder-for-a-select-box
相關文章
相關標籤/搜索