Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

324
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!