Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda