Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
active class for menu and submenu (not only active link) using javascript

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>

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!