// 高亮效果
$("table").find("td").mouseover(function(){
    // 配置行列颜色
    var color = '#CCE8CF';
    // 配置当前单元格颜色
    var currentTdColor = '#97D79E';
    var This = $(this);
    // 将所有的单元格的颜色变为空
    $("table").find("td").css('background-color', '');
    $("table").find("tr").css('background-color', '');
    // 当行前变色
    This.closest("tr").css('background-color', color);
    // 当前列变色
    var index = This.index();
    $.each($("table").find("tr"), function(k, v){
        $(v).children().eq(index).css('background-color', color);
    });
    // 当前单元格变色
    This.css('background-color', currentTdColor);
});
版权声明:本文为李维亮博主的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:http://www.liweiliang.com/395.html

标签: jquery 实现表格当前行列高亮效果

评论已关闭