Prev Demo
jQuery
>
.Focus() - Attach Focus Event To Element
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <style> #txtFocus, #txtFocus1 { padding:5px; } </style> </head> <body> <form> User Id : <input type="text" name="user" id="txtFocus"/> Password : <input type="password" name="password" id="txtFocus1"/> </form> <script> $("#txtFocus, #txtFocus1").focus(function () { alert("got focus"); }); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output