Answers for "js remove class from all elements"

15

how to remove a class from element with javascript

const div =  document.querySelector('div') // Get element from DOM
div.classList.remove('info') // Remove class "info"
Posted by: Guest on January-03-2021
0

remove a class from all elements javascript

var class_name='classname';

elements=document.getElementsByClassName(class_name)

for(element of elements){
  element.classList.remove(class_name)
}
Posted by: Guest on May-26-2021
0

how to remove class in all siblings javascript

const setActive = el => {
    [...el.parentElement.children].forEach(sib => sib.classList.remove('active'))
    el.classList.add('active')
    }
Posted by: Guest on August-30-2020

Code answers related to "js remove class from all elements"

Code answers related to "Javascript"

Browse Popular Code Answers by Language