Change color of elements using jQuery
This should be easy but I'm not getting it for some reason. How would I set the CSS color style (e.g开发者_如何学运维. color:green) of all the elements who are of class 'foobar' using jQuery?
You want the color to go green just on mouseover? Can you be more specific?
$('.foobar').mouseover( function() {
$(this).css( { color: 'green' } );
} );
This can be done with plain CSS:
.foobar {
background-color:red;
}
.foobar:hover {
background-color:green;
}
精彩评论