设置<select> color,FireFox 3.6.17问题</select>

时间:2011-05-18 12:25:56

标签: jquery firefox

这适用于Chrome,Opera,Safari和IE9,但在FF中它设置了白色,为什么?? !!

帮助我PLS

HTML

<select class="widocznosc">
    <option value="prywatna" class="note_0">prywatna</option>
    <option value="publiczna" class="note_2">publiczna</option>
    <option value="tylko dla grupy" class="note_16">tylko dla grupy</option>
</select>

CSS

.note_0
{color: #b59285;
}
.note_2
{color: #e7511e;
}
.note_16
{color: #6a89a5;
}
select.widocznosc
{border: none;
outline: 0;
background-color: #FAFAFA;
width: 110px;
}

的jQuery

jQuery("select.widocznosc").change(function(){
        jQuery(this).css("color", jQuery(this).children("option:selected").css("color")); 
    }).change();

1 个答案:

答案 0 :(得分:2)

您可以改为改变班级: 以下是JS Bin

中的代码

更改后的代码:

jQuery("select.widocznosc").change(function(){        
      jQuery(this).removeClass().addClass(jQuery(this).find("option:selected").
      attr("class"));
}).change();