jQuery表格行换色的三种实现方法
jQuery表格行换色的三种实现方法
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:$('tr').hover(function(event){$(this)[(event.type=='mouseente...

复制代码 代码如下:

$('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了,这个自行测试就知道了。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类