0

次のコードがあります。

$('table tr:not(:first)').mouseover(function() {
  $(this).removeClass('hovered_error');
    $(this).addClass('hovered');
  }).mouseout(function() {
  $(this).removeClass('hovered');
});

上記は、テーブルの最初の行が 'mouseover' および 'mouseout' 関数から除外されることを保証するのに役立ちます。

ただし、問題は、ページに複数のテーブルがあり、最初のテーブル行は無視されますが、残りは無視されないことです。

複数のテーブルを考慮して上記を調整する方法がわかりません-可能ですか?

4

1 に答える 1

1

使用する

$('table tr:not(:first-child)').mouseover(function () {
    $(this).addClass('hovered');
}).mouseout(function () {
    $(this).removeClass('hovered');
});

デモ:フィドル

于 2013-08-30T10:54:37.270 に答える