If you want to change the color of an element when hovering over it, there are a few ways to do so. One way is to use the .hover method in JavaScript (jquery) where you can specify two functions - one for when the mouse moves over the element and another for when it moves out. Here's an example:
1 - Using JavaScript (jquery)
$(document).ready(function(){
$('tr').hover(
function(){
var $this = $(this);
$this.css('background-color', '#fff');
},
function(){
var $this = $(this);
// original color -> $this.css('background-color', $this.data('bgcolor'));
$this.css('background-color', '#000');
}
);
});
You can retrieve the original color using .data('bgcolor')
, which gets the color set by the style attribute or in the original CSS.
2) Alternatively, you can simply add a CSS rule like this:
.row {
background-color: #000;
}
.row:hover {
background-color: #fff;
}
and apply it to the row element like this:
<tr class='row'>
...
</tr>