jquery - how to change the css of default select2 placeholder color? -


i using select2 plugin. in mandatory fields have give select2 placeholder color red.

how change default select2 placeholder color red?

html

<select id="leadadd_mode_of_enq" name="leadadd_mode_of_enq" class="select2 req_place" data-select-search="true" placeholder="mode of enquiry">     <option value="1">opt1</option>     <option value="2">opt2</option> </select> 

css

.req_place::-webkit-select-placeholder{     color:#fff !important; } 

if understand want correctly, want use selector.

original css make placeholder gray

.select2-default {   color: #f00 !important; } 

change preferred placeholder color

.select2-default {   color: #f00 !important; } 

specific placeholder color (using id)

#s2id_<elementid> .select2-default {   color: #f00 !important; } 

replace original input or select id

in case

#s2id_leadadd_mode_of_enq .select2-default {   color: #f00 !important; } 

also, note placeholder work, have add empty <option></option> or else first option automatically selected, not placeholder.

like so

<select id="leadadd_mode_of_enq" name="leadadd_mode_of_enq" class="select2 req_place" data-select-search="true" placeholder="mode of enquiry">   <option></option>   <option value="1">opt1</option>   <option value="2">opt2</option> </select> 

see demo


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -