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

313
Vistas
Setting focus on <button> and making the button show focus (highlighted)

My code is simple:

<html>
<body>
    Test
    <br>
    <button onclick="document.getElementById('btn2').focus();">Button 1</button>
    <br>
    <button id="btn2" onclick="alert('Hello world');">Button 2</button>
</body>
</html>

The question is simple - button one will set focus to button 2. However, the focus is not visible. Only when pressing the Shift key, focus will appear. Focus can also be shown using the tab key, in order to follow focus. I want focus to be visible to the user

My question is how can I set focus and make it visible to the user?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can try make it visible to the user by adding css to the page

https://developer.mozilla.org/en-US/docs/Web/CSS/:focus

<style>
#btn2:focus{
   background-color: blueviolet;
}
</style>
about 4 years ago · Juan Pablo Isaza Denunciar

0

is this is what you want?

button:focus{
  outline: 1px solid red
}
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