I am trying to find out which exact list item was selected in the navigation menu. With this information, I will remove the class active
from the previous menu link and add it to the newly selected one.
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#pageOne">Home</a></li>
<li><a href="#pageTwo">About</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
JavaScript:
let menuClick = document.getElementsByClassName(".nav");
menuClick.addEventListener('click', changeActive(), false);
function changeActive(){
//enter code here
}