we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
showing results for - "first remove active class from classlist and append to current element using javascript"
Catalina
24 Apr 2017
1function myFunction(e) {
2  if (document.querySelector('#navList a.active') !== null) {
3    document.querySelector('#navList a.active').classList.remove('active');
4  }
5  e.target.className = "active";
6}