I am trying to set the navigation tabs to active when I click on the tab. The code that I have here makes the tab active but when I mouse away from the tab and click on another tab, it remains active. How do I get it to become inactive when I go to another tab?
var navbar = document.getElementById("navbar__list");
var tabs = document.getElementsByTagName("li");
for (var i = 0; i < tabs.length; i++) {
tabs[i].addEventListener("click", function() {
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace(" active", "");
this.className += " active";
});
}