I have a basic slider that moves below tabs when you click them, but i would like for it to change color depending on WHICH TAB it currently is. Here is a snippet :
var element = document.querySelectorAll("#home, #web, #design");
for (var i = 0; i < element.length; i++) {
  element[i].addEventListener("click",function(x){
    if(document.querySelector(".active")){
      document.querySelector(".active").classList.remove("active");
    }
    x.currentTarget.classList.add("active");
  });
} #menu {
    width: 50%;
    margin: 0;
    margin-left: 15em;
    text-decoration: none;
    list-style: none;
    text-align: center;
}
#menu ul, #menu li {
    display: inline;
}
#menu a {
    display: inline-block;
    width: 25%;
    padding: .75rem 0;
    text-decoration: none;
    color: lightgray;
    transition: color .15s;
}
#menu a:active {
    color: white;
}
#menu a:hover {
    color: white;
}
#home.active ~ hr {
    margin-left: 14.5%
}
#web.active ~ hr {
    margin-left: 40%
}
#design.active ~ hr {
    margin-left: 65.5%
}
#slider {
    height: .25rem;
    width: 20%;
    margin: 0;
    background: tomato;
    border: none;
    transition: 0.3s ease-in-out;
}<nav>
    <ul id="menu">
        <li id="home" class="active"><a href="#home">Accueil</a></li>
        <li id="web"><a href="#web">Web</a></li>
        <li id="design"><a href="#design">Design</a></li>
        <hr id="slider"/>
    </ul>
</nav>I hope this isn't too stupid or bad, i was trying to figure it out but no luck on my end so hopefully this isn't too much of an issue. Thank you for your time.
 
     
    