jquery

关注公众号 jb51net

关闭
首页 > 网络编程 > JavaScript > javascript类库 > jquery > jQuery表格行换色

jQuery表格行换色的三种实现方法

作者:

一般情况下使用第二种方法是可以的,但是遇到表格行可以拖拽的情况,那么就会出现BUG了,这个自行测试就知道了。
复制代码 代码如下:

$('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了,这个自行测试就知道了。
您可能感兴趣的文章:
阅读全文