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

326
Visualizações
How to check <input> tag is click or not?

I have a input tag like this :

<input type="file" id="excel_file"
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
style="color:transparent; "/>

and the output:

enter image description here

What I trying to do is I want to check whether the Choose File button is clicked or not. I couldn't check with the same method like a normal button cause this choose file is not a button. Does anyone know how can I detect if user is clicking it or not ?

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

0

If you just want to listen for the click event simply use the following:

const inputElement = document.getElementById('excel_file');
inputElement.addEventListener('click', () => {
    console.log('I was clicked');
}, false);

However, if you want to listen for the event of a file selection then you should you use 'change' instead of 'click'. The 'change' event will only trigger when a file is selected avoiding triggering your function if a user clicks the button then exits by clicking on cancel.

For more information: Using files from web applications

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