Question

I have the following code:

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

The above works a treat in ensuring that the first row of a table is excluded from the 'mouseover'and 'mouseout' functions.

However, the issue is I have multiple tables on the page and whilst the first table row is ignored the rest aren't.

I'm not sure how to adapt the above to account for multiple tables - is it possible?

Was it helpful?

Solution

use

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

Demo: Fiddle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top