View Single Post
Old 11-20-2012, 03:52 PM   PM User | #1
kevinkhan
Regular Coder

 
Join Date: Jun 2009
Posts: 350
Thanks: 75
Thanked 0 Times in 0 Posts
kevinkhan is an unknown quantity at this point
jquery - change backround color of html select options

I have this html code

PHP Code:
<p> 
                    <label for="contact">Contact name<span class="required"> *</span></label>
                    <select name="contact" id="contact" onClick="clearSelect(this,'contact')">
                    <option value="">Select Contact</option>
                    <?php foreach ($contacts as $contact): ?>
                        <option value="<?php htmlout($contact['id']); ?><?php
                                
if ($contact['id'] == $contactID)
                                    echo 
' selected="selected"';
                                
?>><?php htmlout($contact['name']); ?></option>
                    <?php endforeach; ?>
                    </select>    
                </p>
and this jquery fuction

PHP Code:
function clearSelect(thisfieldid) {

    
$j("#" id).css("background-color","#FFF");
    
$j("#" id).css("border","1px solid #CCCCCC");
    
$j("#" id).css("color","#000000");

When i click the select book the background of the select box changes to white but the drop down list stays the same color untill you scroll down it.

Any ideas how to change all the option background colors to white when the select box is clicked?
kevinkhan is offline   Reply With Quote