关于jQuery表格行换色的三种方法

$('tr').hover(function(event) {
      $(this)[ (event.type == 'mouseenter' ? 'add' : 'remove') + 'Class' ]('test');     //test是样式
});

$('tr').hover(function(event) {
      $(this).toggleClass('test');  //test是样式
});

$('tr').hover(function(){
     $(this).addClass('test');  //test是样式
},function(){
     $(this).removeClass('test');  //test是样式
});


注:一般情况下使用第二种方法是可以的,但是遇到表格行可以拖拽的情况,那么就会出现BUG了,这个自行测试就知道了。
原文地址:https://www.cnblogs.com/edielei/p/2091244.html