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

111
Views
How can I change the background colour of an list item when on a certain section of a page?

I have a navbar on the top of my page that stays on top of the page at all times;

<div>
<header>
    <nav class='cf'>
        <ul class='cf'>
            <li>
                <a href='#showcase'>Home</a>
            </li>
            <li>
                <a href='#vr-solutions'>VR Solutions</a>
            </li>
            <li>
                <a href='#clients'>Clients</a>
            </li>
            <li>
                <a href="#manufacturing">Manufacturing</a>
            </li>
            <li>
               <a href="#products">Products</a>
            </li>
            <li>
                <a href="#about-us">About Us</a>
            </li>
            <li>
                <a href="#/">Latest News</a>
            </li>
            <li>
                <a href="#/">Gallery</a>
            </li>
        </ul>
            <a href='#' id='openup'>Dropdown</a>
    </nav>
</header>   
</div>

In the body section I have sections with id tags, to which the navbar links scroll to.

<section class="section section-dark" id="vr-solutions">
    <p> content </p>
</section>

<section class="section section-light" id="clients">
    <p> content </p>
</section>

/* and so on */

How do I, with javascript or jquery, change the background colour of the 'li VR Solutions' to red if said section is visible on page, and then back to the previous colour once off screen, and move to the 'li Clients' once it is visible on screen?

The idea is an indicator of where you are on page shown by the navbar.

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!