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

jQuery(element).focusin(handler);
jQuery(element).focusout(handler);

Example

<!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>
Services
Are you searching for a digital partner for your business?

Let’s connect for an enterprise digital solutions to hire developers for software, web and mobile app development.

Looking for a First-Class Business Plan Consultant?