1

jquery -ホバー時に動的テーブルのヘッダー行の背景色を変更しない方法

ヘッダー行の背景色がホバー時に変化することを示すフィドルの例を参照してください。

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

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

2 に答える 2

1

それは条件ですここで実際の例を見てください

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

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

于 2012-11-16T16:53:30.193 に答える
1
}, "#PersonOrgTBL tr:not(:eq(0))");

次のように書くこともできます。

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

フィドルのデモ

于 2012-11-16T16:43:19.107 に答える