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

201
Visualizações
I want to log an action everytime a user clicks (highlights) an input field to enter a value into it. What can I do to achieve such functionality?

I am using React if that helps.

I'm working on some user actions analytics for my website which has a form. I'm adding a logger on some user actions. One of them being I want to log every time the user clicks on the input field to enter some value into it. How can I achieve this functionality?

I was thinking of onClick but I don't think that would be the best way to go about it cause that wouldn't serve the purpose.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

<input onClick={logCount}>

More info about events: https://reactjs.org/docs/handling-events.html

about 4 years ago · Juan Pablo Isaza Relatório

0

I'm not exactly sure why you're claiming an onclick event wouldn't be the right approach.

You can add an ID to the input tag and access it through a JavaScript file, adding an onclick event to it.

<!DOCTYPE html>
<html>
    <body>
        <input type="text" id="test">
        <script>
            document.getElementById('test').onclick = function() {
                console.log('An input field with the id "test" has been clicked.')
            }
        </script>
    </body>
</html>
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