Answers for "javascript add and remove class"

7

javascript remoev css class

//remove a css class from an element
document.getElementById("myElementID").classList.remove("class_name");
Posted by: Guest on July-31-2019
2

es6 add and remove class

let el = document.getElementById('container');

//remove class
el.classList.remove('first');

//remove class
el.classList.add('first');
Posted by: Guest on September-01-2020
2

add to classlist javascript

Add multiple classes to a <div> element:
document.getElementById("myDIV").classList.add("mystyle", "anotherClass", "thirdClass");

Remove a class from a <div> element:
document.getElementById("myDIV").classList.remove("mystyle");

Remove multiple classes from a <div> element:
document.getElementById("myDIV").classList.remove("mystyle", "anotherClass", "thirdClass");

Toggle between two classes for a <div> element:
document.getElementById("myDIV").classList.toggle("newClassName");

Find out if an element has a "mystyle" class:
document.getElementById("myDIV").classList.contains("mystyle");
Posted by: Guest on June-29-2020

Code answers related to "javascript add and remove class"

Code answers related to "Javascript"

Browse Popular Code Answers by Language