Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
How to move focus from button to another button

I tried to focus or trigger but it's not working. Please let me know if you have any knowledge. Thanks in advance!

<button onclick="myFunction()">Click</button>
<button id="close-btn">Focus Button</button>


function myFunction() {
   let closeBtn = document.getElementById('close-btn');
       closeBtn.focus();
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This may solve your problem, the css part is just to show the effect.

document.querySelector('#open-btn').addEventListener('click', ()=>{
  document.querySelector('#close-btn').focus()
})
button:focus {
    border: 2px solid rgb(54, 13, 13);
    background-color: aquamarine;
}
<!DOCTYPE HTML>
<html>

<body>
      <button id="open-btn">Click</button>
      <button id="close-btn">Focus Button</button>
</body>

</html>

about 4 years ago · Juan Pablo Isaza Denunciar

0

Try using

function(e) {
    e.preventDefault();
    .....
}

This will prevent the browser's default behavior of any element.

Thanks!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda