What does the toggleClass() function do in jQuery?
-
A
Adds a class if the element does not have it, removes it if it does
Correct answer
-
B
Adds a class without removing existing classes
-
C
Toggles between two classes
-
D
Removes a class
Correct answer
A. Adds a class if the element does not have it, removes it if it does
16 views
Explanation
toggleClass() adds a class if the element does not have it and removes it if it does.
Doubts & discussion
Not sure why the answer is A? Ask here and get an explanation.
Ask a doubt about this MCQ