$(" > tbody > tr", this).each(function (i) {
//鼠标悬浮样式
$(this).hover(function () {
$(this).addClass(settings.hoverClass);
}, function () {
$(this).removeClass(settings.hoverClass);
});
//鼠标点击样式
if (settings.isClick) {
$(this).bind("click", function () {
$(this).addClass(settings.clickClass).siblings("tr").removeClass(settings.clickClass);
});
}
});
});
}
})();
有些时候我们可能并不需要鼠标点击后的样式,因此设置了isClick这个作为控制开关。如果不想要点击样式,将其设置为false即可。
DEMO如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>表格样式(银光棒)</title>
<style type="text/css">
table{ width:700px; border:1px solid green;border-collapse:collapse;}
table td{height:40px; text-align:center; width:25%;} .tab_even{ background-color: #DDD;}
.tab_odd{ background-color: White;}
.tab_hover{ background-color: Green;color:White;}
.tab_click{ background-color: Orange;}
</style>
</head>
<body>
<table>
<thead>
<tr>
<td>编号</td>
<td>姓名</td>
<td>年龄</td>
<td>操作</td>
</tr>
</thead>
<tbody>
<tr>
<td>1111</td>
<td>1111</td>
<td>1111</td>
<td><input type="button" value="查看" /><input type="button" value="删除" /></td>
</tr>
<tr>
<td>2222</td>
<td>2222</td>
<td>2222</td>
<td><input type="button" value="查看" /><input type="button" value="删除" /></td>
</tr>
<tr>
<td>3333</td>
<td>3333</td>
<td>3333</td>
<td><input type="button" value="查看" /><input type="button" value="删除" /></td>
</tr>
<tr>
<td>4444</td>
<td>4444</td>
<td>4444</td>
<td><input type="button" value="查看" /><input type="button" value="删除" /></td>
</tr>
<tr>
<td>5555</td>
<td>5555</td>
<td>5555</td>










