Answers for "first remove active class from classlist and append to current element using javascript"

1

first remove active class from classlist and append to current element using javascript

function myFunction(e) {
  if (document.querySelector('#navList a.active') !== null) {
    document.querySelector('#navList a.active').classList.remove('active');
  }
  e.target.className = "active";
}
Posted by: Guest on October-28-2020

Code answers related to "first remove active class from classlist and append to current element using javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language