Answers for "document.getElementById("0").classList.add("active"); is not adding class to div with given id"

8

change elements class javascript

document.getElementById("MyElement").classList.add('MyClass');

document.getElementById("MyElement").classList.remove('MyClass');

if ( document.getElementById("MyElement").classList.contains('MyClass') )
{
document.getElementById("MyElement").classList.toggle('MyClass');
}
Posted by: Guest on July-06-2020

Code answers related to "document.getElementById("0").classList.add("active"); is not adding class to div with given id"

Code answers related to "Javascript"

Browse Popular Code Answers by Language