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

如何利用背景颜色对select进行操作?
页面上有多个select。现在通过一个按钮实现:将所有背景颜色为 "#C0C0C0 "的select的disabled属性改为true。(这个页面上不是所有的select的背景颜色都为 "#C0C0C0 ")

------解决方案--------------------
var allSelect = document.getElementsByTagName( "select ");
for (var i=0; i <allSelect.length; i++)
{
if (allSelect[i].style.backgroundColor.toUpperCase() == "#C0C0C0 ")
{
allSelect[i].disabled = true;
}
}

没测,试试看!
------解决方案--------------------
如果不行就用currentStyle[ "background-color "]
------解决方案--------------------
应该是background-color,但是我用for(c in selectID)居然看不到这个属性……
------解决方案--------------------
<select name= " " id= "sel " style= "background-color:red ">
<option> a </option>
<option> b </option>
<option> c </option>
</select>
<script type= "text/javascript ">
// <![CDATA[
alert(sel.currentStyle[ 'backgroundColor '])
for (var i in sel.currentStyle)
document.write(i+ ": "+sel.currentStyle[i]+ " <br/> ")
//]]>
</script>