$("table.datalist tr:nth-child(odd)").addClass("altrow");
<script>
$(document).ready(function() {
$('tr').addClass('odd');
$('tr:even').addClass('even'); //奇偶变色,添加样式
});
</script>
<style>
#hacker tr:hover{
background-color:red; //使用CSS伪类达到鼠标移入行变色的效果,比Jquery 的mouseover,hover 好用
}
.odd {
background-color: #ffc; /* pale yellow for odd rows */
}
.even {
background-color: #cef; /* pale blue for even rows */
}
</style>
</head>
<body>
<table id="hacker">