鼠标经过tr时,改变tr当前背景颜色

时间:2014-01-13    点击:343   
示例如下:
复制代码 代码如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>鼠标经过给tr换颜色</title>   
</head>
<body>
<table align="center" width="100%" border="1" cellspacing="1" cellpadding="1" >
  <tr style="cursor:hand " onmousemove="changeTrColor(this)">
    <td align="center">1</td>
    <td height="20"> 123</td>
    <td height="20"> abvx</td>
    <td height="20"> 465465</td>
    <td height="20">546654654</td>
  </tr>
  <tr style="cursor:hand " onmousemove="changeTrColor(this)">
    <td align="center">1</td>
    <td height="20"> 123</td>
    <td height="20"> abvx</td>
    <td height="20"> 465465</td>
    <td height="20">546654654</td>
  </tr>   
  <tr style="cursor:hand " onmousemove="changeTrColor(this)">
    <td align="center">1</td>
    <td height="20"> 123</td>
    <td height="20"> abvx</td>
    <td height="20"> 465465</td>
    <td height="20">546654654</td>
  </tr>
</table>
<script type="text/javascript">
function changeTrColor(obj){   
    var _table=obj.parentNode;
    for (var i=0;i<_table.rows.length;i++){
        _table.rows[i].style.backgroundColor="";
    }   
    obj.style.backgroundColor="blue";
}
</script>
</form>
</body>
</html>
js判断是否为ie的方法小结
jquery教程限制文本框只能输入数字和小数点示例分享
javascript教程之不完整的继承(js原型链)
javascript函数作用域学习示例(js作用域)
多选列表框动态添加,移动,删除,全选等操作的简单实例
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved