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

115
Visualizações
My multiple logo change on scroll fails at the second 'else if'

I'm trying to change a logo depending on which section it passes through --light logo on dark section and vice versa-- by using the jQuery scrollTop. The first rule executes correctly, the logo changes after 450, but the second rule doesn't execute at 470, which is odd since the else works fine. The logo changes back to its original state. Here's my WP JS snippet:

jQuery(document).on('scroll', function() {
    if (jQuery(this).scrollTop() > 450) {
        jQuery('.navbar-brand img').attr('src','http://localhost/site/wp-content/uploads/2021/09/mini-logo.png');
    } else if (jQuery(this).scrollTop() > 470) {
        console.log("it works");
        jQuery('.navbar-brand img').attr('src','http://localhost/site/wp-content/uploads/2021/09/dark-f-logo.png');
    } else {
        jQuery('.navbar-brand img').attr('src','http://localhost/site/wp-content/uploads/2021/09/dark-f-logo.png');
    }
});

Thanks for taking a look.

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