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
Release: 2016-05-16 18:05:41
Original
1387 people have browsed it
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.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template