简体   繁体   English

jquery - 如何在悬停时不更改动态表标题行的背景颜色

[英]jquery - how to not change background color of header row of dynamic table on hover

jquery - how do I not change the background color of header row of dynamic table on hover I have a dynamic table that is being built with jquery and am using the .on jquery - 如何在悬停时更改动态表标题行的背景颜色我有一个使用 jquery 构建的动态表并且正在使用 .on

See fiddle example that shows the header row bg color does change on hover.请参阅显示标题行 bg 颜色在悬停时更改的小提琴示例

http://jsfiddle.net/remy/sCGRL/ http://jsfiddle.net/remy/sCGRL/

$(document).on({
    mouseenter: function () {
        $(this).css("background-color", "lightgoldenrodyellow");
    },
    mouseleave: function () {
        $(this).css("background-color", "");
    }
}, "#PersonOrgTBL tr");
}, "#PersonOrgTBL tr:not(:eq(0))");

You can also write it like:你也可以这样写:

$(document).on('mouseenter mouseleave','#PersonOrgTBL tr:not(:eq(0))', function( e ){
    var color = e.type=='mouseenter' ? "lightgoldenrodyellow" : "";
    $(this).css({backgroundColor: color});
});

fiddle demo小提琴演示

It is a condition do look here a practical example这是一个条件,看看这里的一个实际例子

if(!$(this).is(":first-child")) {
    $(this).css("background-color", "lightgoldenrodyellow");
}

http://jsfiddle.net/sCGRL/12/ http://jsfiddle.net/sCGRL/12/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM