i am using a dreamweaver template for my navigation menu, so I am unable to set the active class and I still want to set my active link color. this javascript code (thank you Online Tutorials) is working wonderful, but not with the main menu, when it has a dropdown menu. when I choose a link in the dropdown menu, it shows the red color (as seen in the attachment) but when I click and open the page from the dropdown menu, there is no active link color in the main menu anymore.. anyone has a tipp ?
<script type="text/javascript">
const currentLocation = location.href;
const menuItem = document.querySelectorAll('a');
const menuLenght = menuItem.length
for (let i = 0; i<menuLenght; i++){
if(menuItem[i].href === currentLocation){
menuItem[i].className = "active"
}
}
</script>