590
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
window.onload = function(){
var hang = document.getElementsByTagName("tr");
for(var i=0; i<hang.length; i++){
hang[i].onmouseover = function(){
this.style.backgroundColor = "red";
};
hang[i].onmouseout = function(){
this.style.backgroundColor = "#fff";
};
}
}
</script>
</head>
<body>
<table border="1" width="50%" id="table">
<tr>
<th>学号</th>
<th>姓名</th>
<th>操作</th>
</tr>
<tr>
<td>xh001</td>
<td>王小明</td>
<td><a href="#" >删除</a></td>
</tr>
<tr>
<td>xh002</td>
<td>刘小芳</td>
<td><a href="#" >删除</a></td>
</tr>
</table>
<input type="button" value="添加一行"/>
</body>
</html>
hang[i].onmouseover = function(){
this.style.backgroundColor = "red";
};