今天项目经理让做个页面是隔行变色的,我也不是美工找了半天,不过最后成功了,这样就不用每行中都写样式;哈哈哈,很好用! Jquery 很强大!

 

$(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 >