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

·如何通过 document.getElementById(ID) 获得控件的背景颜色值?
function   ck(id)
{
document.getElementById(id).style.backgroundColor;//大概意思,但这样不对
}
</script>

------

<table   width= "80% "   border= "1 ">
    <tr   id= "tr1 "   bgcolor= "#ff0000 ">
        <td   colspan= "3 ">
            <input   type= "checkbox "   name= "checkbox "   value= "1 "   onclick= "ck( 'tr1 ') "   />
        </td>
    </tr>
</table>

------解决方案--------------------
try

document.getElementById( "tr1 ").style.backgroundColor = "red ";