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

265
Views
How to know if an input is clicked and unclicked in Javascript

I'm trying to figure out how to know when an input is clicked and when it is unclicked. Let me explain:

When ever you want to type something on an input field, you click on the input box and when you don't want to type, you click somewhere else and the input field is disabled.

<input type='text'>

Here as you can see, when you click on it, the field is enabled, and when you click somewhere else other than the field, it disables.

I just want to know when the field is disabled/unclicked.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

When you click on the input field focus event is fired. When you lose focus blur event is fired.

var elem = document.getElementById("fname")

elem.addEventListener("blur", myFunction);

function myFunction() {
  alert("Input field lost focus.");
}
<input type="text" id="fname">

about 4 years ago · Juan Pablo Isaza Report

0

I believe you're just looking for onFocus.

<input type='text' onFocus={/* do something */} />

Read more about React events here.

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!