<!DOCTYPE html>标签:style,1.2,DOM,js013,js,backgroundColor,trs From: https://www.cnblogs.com/lfyxys/p/16919685.html
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<table border="1">
<thead>
<tr>
<th>IP</th>
<th>端口</th>
</tr>
</thead>
<tbody id="i1">
<tr><td>1.2.3.6</td><td>8888</td></tr>
<tr><td>1.2.335.6</td><td>9999</td></tr>
<tr><td>1.2.335.99</td><td>9933</td></tr>
</tbody>
</table>
<script>
var trs = document.getElementById('i1').children;
for(var i = 0;i<trs.length;i++){
trs[i].onmouseover = function (){
this.style.backgroundColor = '#e75e15';//记得用‘this’,当前这个对象
}
trs[i].onmouseout = function (){
this.style.backgroundColor = '';
}
}
</script>
</body>
</html>