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

312
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

is this is what you want?

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