Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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";
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #active #class #classlist #append #current #element #javascript
ADD COMMENT
Topic
Name
4+6 =