1. Home
  2. Computer Science MCQs
  3. Jquery
  4. What does the toggleClass() function do in jQuery?

Added 30 Jan 2024

What does the toggleClass() function do in jQuery?

  1. Adds a class if the element does not have it, removes it if it does Correct answer
  2. Adds a class without removing existing classes
  3. Toggles between two classes
  4. Removes a class

Correct answer

A. Adds a class if the element does not have it, removes it if it does

16 views

MCQSEXAM

Explanation

toggleClass() adds a class if the element does not have it and removes it if it does.

Reference

https://www.w3schools.com/jquery/default.asp

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Jquery MCQs

Practise all Jquery MCQs

Similar MCQs