开发者

Change color of elements using jQuery

开发者 https://www.devze.com 2022-12-15 14:56 出处:网络
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 wa

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;
} 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号