日期:2014-05-16 浏览次数:20496 次
<!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> <title></title> <style type="text/css"> .odd{ background-color:Yellow; } .even{ background-color:Gray; } .tdGroup { background-color:Green; } .mouseOver{ background-color:Red; } </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $.fn.ChangeOddEvenTrColor("tbodyList", "odd", "even", true, "pointer", "mouseOver"); $.fn.ChangeOddEvenTrColorWithGroup("tableList", "odd", "even", "tdGroup", false, true, "pointer", "mouseOver"); $.fn.ChangeOddEvenTrColorWithGroup("tableList2", "odd", "even", "tdGroup", false, false, "pointer", "mouseOver"); }); //===================================================================== //插件名称: ChangeOddEvenTrColor //作 者: yenange //功能说明: 设置奇偶行换色 //输入参数: 表格(table或tbody)id, 奇行class, 偶行class, 是否从第一行开始 //调用示例: $(function(){ $.fn.ChangeOddEvenTrColor("table1", "odd", "even", true,"pointer","mouseOver"); }); //输出参数: //创建日期: 2011-09-01 (function ($) { jQuery.fn.ChangeOddEvenTrColor = function (tabId, oddClass, evenClass, fromFirstTr, cursor, mouseOverClass) { var $obj = fromFirstTr ? $("#" + tabId + " tr") : $("#" + tabId + " tr").not(":first"); $obj.filter(":odd").addClass(oddClass).css("cursor", cursor); $obj.filter(":even").addClass(evenClass).css("cursor", cursor); if (typeof (mouseOverClass) != "undefined") { $($obj).each(function () { $(this).mouseover(function () { $(this).addClass(mouseOverClass); }).mouseout(function () { $(this).removeClass(mouseOverClass); }); }); } } })(jQuery); //===================================================================== //插件名称: ChangeOddEvenTrColorWi