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

187
Views
JS - modify dom element to display onload when navigating from a page nav bar option using onclick function

I have written code that toggles the display of a home page element from an option in the nav bar which works. However I would also like this code to execute on load when the same option is selected to navigate back to my home page and display element.

Currently it navigates to the home page but does not apply the display changes to show element on load and nav bar option has to be clicked again to display element.

this is my code

abNav = () => {

    abLoad = () => {
            about.style.display = "block";
            design.style.display = "none";
            program.style.display = "none";
            project.style.display = "none";
            contact.style.display = "none";
    }

    if (
        window.location.href === "./index.html#home"
    ){
        window.onload = abLoad();
    } else {
       return abLoad();
    }

}

HTML Nav bar option with onclick function

<li>
   <a href="#home" id="about-nav" onclick="abNav()">About</a>
</li>
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!