标签搜索

html--表格高亮显示

冰封一夏
2021-09-29 00:50:38 / 87 阅读 / 正在检测是否收录...

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">function changeColor(id,flag){
if(flag=="over"){
document.getElementById(id).style.backgroundColor="red";
}else if(flag=="out"){
document.getElementById(id).style.backgroundColor="white";
}
}
</script>
</head>
<body>
<table border="1px" width="100px" height="100px" align="center">
<thead>
<tr onmouseover="changeColor('t1','over')" onmouseout="changeColor('t1','out')" id="t1">
<th>d</th>
<th>dx</th>
</tr>
</thead>
<tbody>
<tr onmouseover="changeColor('t2','over')" onmouseout="changeColor('t2','out')" id="t2">
<td>s1</td>
<td>s2</td>
</tr>
<<tr onmouseover="changeColor('t3','over')" onmouseout="changeColor('t3','out')" id="t3">
<td>s3</td>
<td>s4</td>
</tr>
</tbody>
<table>
</body>
</html>

8

评论

博主关闭了所有页面的评论