<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>表格悬停变色Demo</title>
<style type="text/css">
.hover {
background: #00f;
color: #fff;
}
table {
/*border-collapse设置表格的行和单元格的边是合并在一起还是按照标准的HTML样式分开
可以取 separate | collapse */
border-collapse: collapse;
}
</style>
<script src="../jquery-1.5.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('tbody tr').hover(
function(){
$(this).find('td').addClass('hover');
},
function(){
$(this).find('td').removeClass('hover');
}
);
});
</script>
<body>
<table border="1">
<thead>
<tr>
<th>Roll</th><th>Name</th><th>Mark</th>
</tr>
</thead>
<tbody>
<tr>
<td>101</td><td>John</td><td>89</td>
</tr>
<tr>
<td>102</td><td>Bobo</td><td>90</td>
</tr>
<tr>
<td>103</td><td>Cathy</td><td>92</td>
</tr>
<tr>
<td>101</td><td>Duke</td><td>98</td>
</tr>
</tbody>
</table>
</body>
</html>
转载于:https://www.cnblogs.com/ll-taj/p/5949981.html