简体   繁体   中英

change style on hover for element

The element class walkingRoute-container is between a link tag, and I wonder how to do, to highlight an element with a color that stays when a click is made on the element and removed when a click is made on another element, but not when hover? I would also like to change the <p> inside the element to another color when hover?

Appreciate some help.

Thanks!

Code is as below

$(document).ready(function(){
$(".walkingRoute-container").hover(
function(){
   $(this).css("background","#02baff");
},
function() {
  $(this).css("background","#c1c1c1");
})

});

JQuery function css also takes parameter like json object.

var obj = {
    'height': 100,
    'width': 100,
    'background', 'red'
    };

$(element).css(obj);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM