S
S
supercoder6662020-04-22 16:34:17
JavaScript
supercoder666, 2020-04-22 16:34:17

How to make smooth removeClass?

Hello! When you hover the mouse, the class is assigned smoothly, but when I remove the mouse, the class disappears instantly. How can I make the class disappear smoothly?

$(".div").hover(function(){
      $('.link').addClass('menuh');
      }, function(){
      $(".link").removeClass('menuh');
});

css:
.menuh {
  transition: all 0.4s;
  color:red;

}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valentin Birulya, 2020-04-22
@nykakdelishki

$(".div").hover(function(){
      $('.link').addClass('menuh');
      }, function(){
      $(".link").removeClass('menuh');
});

.link {
      transition: all 0.4s;
}

A
Ankhena, 2020-04-23
@Ankhena

I think that you have not specified the color in the initial state .
Those. in CSS it should be like this:

.link {
  color:green;
  transition: all 1s;
}
.menuh {
  color:red;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question