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

146
Views
Mi página se recarga automáticamente cuando hago clic en el botón desplegable

Solo soy un novato en javascript, estoy usando formularios de varias líneas y no puedo encontrar la razón por la cual mi página se vuelve a cargar cuando hago clic en el botón desplegable y sigue volviendo a la primera página de mi formulario.

aquí está mi código en el menú desplegable

 <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>

aquí está el 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 answers
Answer question

0

Primero elimine la propiedad href de las etiquetas de los button .

href es una propiedad de a etiqueta.

y si desea cancelar el evento del botón, agregue esto a su código event.preventDefault()

aquí un ejemplo:

 <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 Report
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!