MCQ Answer

Which method is used to toggle a class on an element?

Which method is used to toggle a class on an element?

किसी तत्व पर कक्षा को टॉगल करने के लिए किस विधि का उपयोग किया जाता है?
Topic : JS DOM Manipulation

A. classList.add()

B. classList.remove()

C. classList.toggle()

D. classList.replace()




Correct Answer is :

C. classList.toggle()



Explanation
The toggle() method of the classList property adds a class if it doesn't exist and removes it if it does. This is useful for switching between states (e.g., light/dark themes).
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad