js给table的单双行添加事件或属性

//table的id为xxx,

//  tr行数为双时,鼠标滑过的属性

$('#xxx tr:even').mouseover(function() {
             $(this).css("background", "red");
         });
//  tr行数为单时,鼠标滑过的属性        
         $('#xx tr:odd').mouseover(function() {
             $(this).css("background", "blue");
            });

//  给所有单行tr添加class属性
         $('#xxx tr:odd").addClass("altrow");
        // 鼠标移出是事件
         $('#cp_'+array[m]+" tr").mouseout(function() {
             $(this).css("background", "");
         });

原文地址:https://www.cnblogs.com/dayu007/p/6513164.html