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

221
Views
Impedir la configuración predeterminada en la pantalla, pero permitir que se presionen los botones

Estoy construyendo un sitio web en js/html/css. Para jugar parte de mi juego, el usuario debe mantener presionada la pantalla. De forma predeterminada, se resaltará el área de reproducción, por lo que al hacer clic o tocar eventos, quiero usar un event.preventdefault() . El problema entonces es que el usuario no puede hacer clic en otros botones de la página.

¿Hay alguna manera de evitar el valor predeterminado al hacer clic y mantener presionado, pero también permitir que los botones funcionen normalmente?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Creo que algo como esto podría funcionar. Básicamente, usar una variable booleana para detectar si se ha hecho clic en un botón específico y luego agregar una declaración condicional a e.preventDefault() para que cuando se haga clic en el botón no se vea afectado por e.preventDefault()

 let isClicked = false document.getElementById('myBtn').addEventListener('click', () => { isClicked = true setTimeOut(() => { isClicked = false }, 100) }) function myPreventDefaultFunction(e){ if(isClicked){ // do something } else{ e.preventDefault() } }
about 4 years ago · Santiago Gelvez 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!