首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

报表间隔换色js

2012-09-13 
表格间隔换色js玩法:给table加一个DataTable的class。?第一版?$(document).ready(function () {??? //间隔

表格间隔换色js

玩法:给table加一个DataTable的class。

?

第一版

?

$(document).ready(function () {
??? //间隔换色
??? $("table.DataTable").each(function () {
??????? $(this).bind("stripe", function () {
??????????? $("tbody tr", this).each(function (index) {
??????????????? if ($("th", this).length) {
??????????????????? $(this).addClass("subhead");
??????????????? }
??????????????? else {
??????????????????? $(".DataTable tr:even").not("tr:first").addClass("even");
??????????????????? $(".DataTable tr:odd").addClass("odd");
??????????????? }
??????????? });
??????? });
??????? $(this).trigger("stripe");
??? });
});

?

升级版

?

$(document).ready(function () {
??? //间隔换色
??? $(".DataTable tbody tr:has(th)").addClass("subhead");
??? $(".DataTable tr:even").not("tr:first").addClass("even");
??? $(".DataTable tr:odd").addClass("odd");
});

热点排行