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

01 $('tr').hover(function(event) {
02       $(this)[ (event.type == 'mouseenter' ? 'add' : 'remove') + 'Class' ]('test');     //test是样式
03 });
04  
05 $('tr').hover(function(event) {
06       $(this).toggleClass('test');  //test是样式
07 });
08  
09 $('tr').hover(function(){
10      $(this).addClass('test');  //test是样式
11 },function(){
12      $(this).removeClass('test');  //test是样式
13 });


注:一般情况下使用第二种方法是可以的,但是遇到表格行可以拖拽的情况,那么就会出现BUG了,这个自行测试就知道了。
posted @ 2011-06-27 22:28  rob_2010  阅读(144)  评论(0)    收藏  举报