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

88
Visualizações
My automatic header with javascript won't close in any page

So a few days ago, I had a small problem. My website has a header normal menu, and I wanted to made it automated with javascript. When I try to find bugs I found a little problem you can see in the image:

Problem image

Normal menu image

My menu working well all the time but after I created javascript code:

        <!-- header begin -->
    <div id="nav-placeholder">
        <script>
            $.get("nav.html", function(data) {
                $("#nav-placeholder").replaceWith(data);
            });

        </script>
    </div>
    <!-- header close -->

This code made my menu load from the nav.html file, okei finally. When I load my menu from nav.html it won't work well, but if I use the code normally in the index.html file it works great.

Maybe I miss something? Only happen in the mobile version, after I press any link in hamburger menu.

Thank you!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

My first comment:
You are replacing data in nav-placeholder div., which will replace the script. So, keep the script outside the that div.

    <script>
        $.get("nav.html", function(data) {
            $("#nav-placeholder").replaceWith(data);
        });

    </script>

<div id="nav-placeholder">
</div>

About your problem:
You are getting all the content from nav.html. So when you try to load the content from inside nav.html, it won't work as expected. So, make a copy of nav.html and name it as content.html or so. Then use content.html in both files.

Note:
Make sure the path is provided correctly

about 4 years ago · Juan Pablo Isaza Relatório
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