日期:2014-05-16  浏览次数:20343 次

关于select option!!!!
(javascript)我想在select的new   option让文字或背景显示不同的色彩?
生成后的:
new   Option( 'text ', 'value ');
想在这里加上色彩,如果不可以的话还有什么别的办法

------解决方案--------------------
<SCRIPT>
function testGG()
{
var xx = document.getElementById( "xxx ");
var oOption = document.createElement( "OPTION ");
xx.options.add(oOption);
oOption.innerText = "Two ";
oOption.value = "2 ";
oOption.style.background = "blue "
}

</SCRIPT>
<BODY>
<select id = "xxx ">
</select>
<input type= "button " value= "add " onClick= "testGG() ">
</BODY>