The following javascript is used to click on a tab and style it with the active class. After it applies the style, it doesn’t persist. I want the tab to remain in the active state even after it has been clicked.
const tabs = document.getElementsByTagName("li");
for (const i = 0; i < tabs.length; i++) {
tabs[i].addEventListener("click", function() {
const current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace("active");
this.className += "active";
});
}
This is for an assignment so it has to be javascript and not jQuery.