Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

javascript - Remove class on mouseleave

I have jQuery code that adds class feather to the div on mouseover if it has class active-s-c-card. I need to remove this class on mouseleave. Would be happy for any suggestions how to improve the current code. Thanks!

jQuery(document).ready(function($) {
  $("body").on("mouseover" ,function(){
    if ($(".panel-s-c-3").hasClass("active-s-c-card")) {
      $(".panel-s-c-3").addClass("feather");
    }
  });
});
question from:https://stackoverflow.com/questions/66059567/remove-class-on-mouseleave

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There you go, when leaving the active-s-c-card element:

$(".active-s-c-card").on("mouseleave" ,function(){
  $(this).removeClass("feather")
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...