html - How to style select dropdown only when value is empty -


lets have markup this:

<select>     <option value="">select</option>     <option value="1">one</option>     <option value="2">two</option>     </select> 

now, want dropdown display in gray when value empty i.e when showing "select". when user has selected 1 of options, should black / default color.

(this visually consistent textboxes on page have gray placeholders).

i want accomplish this:

select[value=""] {     color: gray; } 

but turns out select tag doesn't have value attribute.

any way accomplish other using javascript?

<select name="background" size="1" onchange="updatetextcolour(this.value);"><!--changecolor(this.selected);"-->             <option style="color:gray">select</option>             <option style="color:black">value 1</option>             <option style="color:black">value 2</option> </option>         </select></span></span></td> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -