table行颜色设置

function renderingTable(obj){
    $(obj).each(function(){
        //设置奇数行颜色
        $(this).find("tr:even").css("background-color", '#e9f3fa');

   //设置偶数行颜色

   $(this).find("tr:odd").css("background-color", "#f0f0f0");

   //鼠标移动到首行对首中的<td>元素变色   hover用法关键
        $(this).find("tr:eq(0) td").hover(
                function(){$(this).attr("bColor", $(this).css("background-color")).css("background-color", "#cceaff").css("cursor", "pointer");},
                function(){$(this).css("background-color", $(this).attr("bColor"));}
        );

   //鼠标移动到其他行变色   hover用法关键
        $(this).find("tr:not(:first)").hover(
                function(){$(this).attr("bColor", $(this).css("background-color")).css("background-color", "#cceaff").css("cursor", "pointer");},
                function(){$(this).css("background-color", $(this).attr("bColor"));}
        );
    });
}

你可能感兴趣的:(table行颜色设置)