Toggleclass doesn't seem to switch the class, what am I doing wrong?

I am trying to make a button a class switch, and also show another one below.

Here is the jsFiddle example I made for you .

The first function works fine, shows and hides the div, but also I want the button itself to add and remove a class, I thought it would work, but I seem to be doing something wrong.

Thank.

+3
source share
2 answers
$("this").toggleClass("chev-up");

it should be

$(this).toggleClass("chev-up");
+6
source

Change $("this")to $(this). You do not need quotation marks, because thisis a keyword that refers to itself.

+2
source

Source: https://habr.com/ru/post/1747508/


All Articles