Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove multiple select default background

I have this multiple select for which I want to change the default background for an individidual <option>

<select size="8" name="lstSelectedPackages" style="width:100%">
  <option value="" selected="selected">Select</option>
</select>

fiddle: http://jsfiddle.net/ux4DD/180/

Thank you!

like image 404
BurebistaRuler Avatar asked Aug 04 '26 13:08

BurebistaRuler


1 Answers

If jQuery is best for you then i am sure this will surly help.

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">

    $(function()
    {

        $("select option:selected").each(function ()
        {
            $(this).css('background-color','red');
        });

    });

</script>
<select name="garden">
    <option>Flowers</option>
    <option selected="selected">Shrubs</option>
    <option>Trees</option>
    <option>Bushes</option>
    <option>Grass</option>
    <option>Dirt</option>
</select>
<div></div>
like image 200
Dipesh Parmar Avatar answered Aug 07 '26 04:08

Dipesh Parmar