E
E
Evtera2020-04-17 12:40:18
JavaScript
Evtera, 2020-04-17 12:40:18

How to remove all classes except one Jquery?

There are three columns. When hovering with the mouse, it is $(this)highlighted with the help of additional classes, when it mouseleavereturns to its original state.

But one column is already initially highlighted and has additional classes for this in html. The question is how to make it so that when you hover over another column, the one that was originally highlighted becomes inactive again, i.e. he had his classes removed.

Now it turns out that when you hover over other columns, the active one continues to be highlighted no matter what, which is otherwise logical

$(".price__column").on("mouseenter mouseleave", () => {
    $(event.currentTarget).toggleClass("price__column_active");
    $(event.currentTarget)
      .find(".column__period")
      .toggleClass("column__period_active");
    $(event.currentTarget).find(".button").toggleClass("button_active");
  });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question