Home >Web Front-end >JS Tutorial >Three implementation methods of jQuery table row color change_jquery

Three implementation methods of jQuery table row color change_jquery

WBOY
WBOYOriginal
2016-05-16 18:05:411379browse
Copy code The code is as follows:

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

$('tr').hover(function(event) {
$(this).toggleClass('test'); //test is style
});

$( 'tr').hover(function(){
$(this).addClass('test'); //test is style
}, function(){
$(this).removeClass( 'test'); //test is style
});

Note: Under normal circumstances, it is okay to use the second method, but when encountering table rows that can be dragged, Then there will be a BUG, ​​and you will know it through self-testing.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn