let links = document.querySelectorAll(".nav-tabs li");//for the li tags and the class of the container they're in to find them let bodyId = document.querySelector("body").id; for(let link of links) { if (link.dataset.active == bodyId)//if the active link's data attribute is equivalent to the body id { link.classList.add("active");//uses subclass created in the css document }//change the link's class }