Report Bug
Qus : Which method is used to toggle a class on an element?
Qusकिसी तत्व पर कक्षा को टॉगल करने के लिए किस विधि का उपयोग किया जाता है?

A. classList.add()
B. classList.remove()
C. classList.toggle()
D. classList.replace()


Solution
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).



Report Bug