<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
td {
width: 100px;
height: 26px;
}
</style>
</head>
<body>
<table border="1">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<script src="./jquery-1.12.1.min.js"></script>
<script>
// $("td:odd").css("background","pink");
// 隔列变色
//每一行的偶数列背景色改变
$('tr').each(function(){
$(this).children(':even').css('background','pink');
})
$('tr').mousemove(function(){
$(this).css('background','skyblue').children(':even').css('background','');
})
$('tr').mouseout(function(){
$(this).css('background','').children(':even').css('background','pink');
})
</script>
</body>
</html>
如图
image.png
网友评论