<tr style=" height:32px;" align="center" onmouseover="on(this);" onmouseout="out(this);">
<td width="200">文字</td>
<td width="150">文字</td>
<td width="270">文字</td>
<td width="100">文字</td>                
<td width="100">文字</td>
<td width="100" >文字</td>
</tr>        写个function on(obj){
}
function on(obj){
obj.color="red";
}这个不行

解决方案 »

  1.   

    obj.style.color = "red";也不行
      

  2.   


    function on(obj){
        var tds = obj.getElementsByTagName("td");
        for(var i=0;i<tds.length;i++) {
            tds[i].style.color = "red";
        }
    }
      

  3.   


    function on(obj){
        var tds = obj.getElementsByTagName("td");
        for(var i=0;i<tds.length;i++) {
            tds[i].style.color = "red";
        }
    }
         思路是行得通,但我这边还是没变化
      

  4.   


    完整代码贴上来看看。
    本来直接改tr的style也是可以的,我以为你css里面有设过td的color,但是我这段代码直接改的是td的style
    ,应该是没有问题的。除非你别的地方有js报错了~
      

  5.   

    <table><tr style=" height:32px;" align="center" onmouseover="on(this);" onmouseout="out(this);">
    <td width="200">文字</td>
    <td width="150">文字</td>
    <td width="270">文字</td>
    <td width="100">文字</td>                
    <td width="100">文字</td>
    <td width="100" >文字</td>
    </tr><tr style=" height:32px;" align="center" onmouseover="on(this);" onmouseout="out(this);" style="color:">
    <td width="200">文字</td>
    <td width="150">文字</td>
    <td width="270">文字</td>
    <td width="100">文字</td>                
    <td width="100">文字</td>
    <td width="100" >文字</td>
    </tr></table>
    <script type="text/javascript">
        function out(obj) {
            obj.style.color = 'black';
        }
        function on(obj) {
            obj.style.color = 'red';
        }
    </script>