I have many select in 2 types. Type A is a custom my select, and type B is default select in browser but has custom background.
My CSS:
select {
background: #fff url('down-arrow.png') no-repeat center right !important;
-moz-appearance: none;
text-indent: 1px;
text-overflow: '';
}
Type A:
<select class="positionAbsolute prefCodes" size="4">
<option value>Select Preferred Code</option>
<option value="1063473072">display 1 (NPI: 1063473072)</option>
<option value="1104875822">display 2 (NPI: 1104875822)</option>
</select>
Type B:
<select class="formfield">
<option value="select">Select</option>
<option value="Male">Male</option>
<option value="Female">Female</option><option value="N/A">N/A</option>
</select>
When the page load, I want to use jQuery load all select element. If select has class prefCodes, I want to set background for it is none. And option in this with no value <option value>Select Preferred Code</option>
will add bolder
class. Here my code:
$(document).ready(function () {
if ($("select").hasClass("prefCodes")){
$(this).css("background","none","important");
$(".prefCodes option[value=]").addClass("bolder");
}
});
But it's not work. How to resolve it?