本文实例讲述了jQuery实现Table表格隔行变色及高亮显示当前选择行效果。分享给大家供大家参考,具体如下:
最近客户要求高亮选择列表的功能,于是顺便做了个,作为记录。

前台代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JQuer的鼠标悬浮,鼠标高亮效果</title>
<style type="text/css">
#header
{
background-color:#00ffff;
text-align:center;
}
.style1
{
text-align: right;
}
.style2
{
text-align: center;
}
</style>
<link href="tables.css" rel="external nofollow" rel="stylesheet" type="text/css" />
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
doChangeColorOfRow("#tableThis tr:even:not(#header)", "#tableThis tr:odd:not(#header)");
});
function doChangeColorOfRow(evenTR, oddTR) {
$(evenTR).each(function() {
$(this).css("background-color", "#F0F8FF").bind("mouseover", function() {
if ($(this).css("background-color") != "#ffff00") {
$(this).css("background-color", "#D8FAD8");
}
}).bind("mouseout", function() {
if ($(this).css("background-color") != "#ffff00") {
$(this).css("background-color", "#F0F8FF");
}
}).bind("click", function() {
$(evenTR).each(function() {
if ($(this).css("background-color") == "#ffff00") {
$(this).css("background-color", "#F0F8FF");
}
});
$(oddTR).each(function() {
if ($(this).css("background-color") == "#ffff00") {
$(this).css("background-color", "#ffffff");
}
});
$(this).css("background-color", "#ffff00");
});
});
$(oddTR).each(function() {
$(this).css("background-color", "#ffffff").bind("mouseover", function() {
if ($(this).css("background-color") != "#ffff00") {
$(this).css("background-color", "#D8FAD8");
}
}).bind("mouseout", function() {
if ($(this).css("background-color") != "#ffff00") {
$(this).css("background-color", "#ffffff");
}
}).bind("click", function() {
$(evenTR).each(function() {
if ($(this).css("background-color") == "#ffff00") {
$(this).css("background-color", "#F0F8FF");










