- January 2, 2019
- Posted by: iSummation Team
- Category: Development
No Comments

To delegate the “focus” and “blur” events you must use these new events, called “focusin” and “focusout“. You can also use old events for
handling focusing events in jQuery 14.
Syntax
1 2 |
jQuery(element).focusin(handler); jQuery(element).focusout(handler); |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript" language="javascript" src="jquery-1.4.2.min.js"></script> <script> jQuery(function(){ jQuery('#focus').focusin(function(){ jQuery(this).addClass('focused').val('Focus In'); }); jQuery('#focus').focusout(function(){ jQuery(this).removeClass('focused').val('Focus Out'); }); }); </script> <style> .focused{ background-color : #00f0ff; } </style> </head> <body> <input type="text" name="focus" id="focus" /> </body> </html> |