
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery focusin Event with Example
The focusin() method in jQuery occurs when an element gets focus.
Syntax
The syntax is as follows −
$(selector).focusin(function)
Example
Let us now see an example to implement the jQuery focusin() method −
<!DOCTYPE html> <html> <head> <style> .demo { color: blue; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("input").focusin(function(){ $("p").html("focusin event triggered"); }); $("input").focusout(function(){ $("p").html("focusout event triggered"); }); }); </script> </head> <body> <h2>Student Details</h2> Student Name: <input type="text"><br> <br><br> <p class="demo"></p> </body> </html>
Output
This will produce the following output −
Now, click inside to get focus −
Click outside to lose focus −
Advertisements