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

152
Visualizações
My Page is automatically Reloading when I click the dropdown button

I'm just a newbie in javascript, I'm using a multiline forms and I can't find the reason why my page is reloading when I click the dropdown button and it keeps getting back on the first page of my form.

here is my code in the dropdown

 <div class="container3">
      <button class="click" name="drop" href="#">
        Select hours
      </button>
      <div class="list">
        <button class="links" href="#">6 Hours</button>
        <button class="links" href="#">8 Hours</button>
        <button class="links" href="#">10 Hours</button>
        <button class="links" href="#">16 Hours</button>
        <button class="links" href="#">20 Hours</button>
      </div>
    </div>

here is the javascript:

 <script>
      let click = document.querySelector('.click');
      let list = document.querySelector('.list');
      click.addEventListener("click", ()=>{
        list.classList.toggle('newlist');
      });
    </script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

First remove href property from button tags.

href is a property of a tag.

and if you want to cancel event of button add this to your code event.preventDefault()

here an example:

 <script>
      let click = document.querySelector('.click');
      let list = document.querySelector('.list');
      click.addEventListener("click", (event)=>{
        event.preventDefault()
        list.classList.toggle('newlist');
      });
 </script>
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