$(function () {
//even代表了table表中tr行數爲偶數行;
$(".bjyxfm tr:even").SetTableSeparatorUI();
});
Html頁面中的代碼是:
隔行變色的事件爲以下:
//表單中隔行變色
$.fn.SetTableSeparatorUI = function () {
$(this).css({ "background": "#fff" });
}
<div>
<table id="pgdx" class="bjyxfm" title=" 評估對象表" border="0" cellpadding="0" cellspacing="1">
<tr >
<th >
報告編號
</th>
<td colspan="3" >
<input id="txtProjectCode" name="txtProjectCode" class="txt_450" type="text" />
</td>
</tr>
<tr>
<th>
項目名稱
</th>
<td colspan="3">
<input id="txtProjectName" name="txtProjectName" class="txt_450" type="text" />
</td>
</tr>
</table>
</ div >