JS - active class on navigation

0 votes
231 views
added May 8, 2019 in Javascript by LC Marshal Captain (25,790 points)
  var nav = document.getElementById("nav");
  var menu = header.getElementsByClassName("menu");
  for (var i = 0; i < menu.length; i++) {
    menu[i].addEventListener("click", function() {
    var current = document.getElementsByClassName("active");
    current[0].className = current[0].className.replace(" active", "");
    this.className += " active";
    });
  }

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...