Development

jQuery New Event! Focusin and Focusout

jQuery New Event! Focusin and Focusout

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>
[stm_post_bottom][stm_post_about_author][stm_post_comments]

Looking for a First-Class Business Plan Consultant?

Share LinkedIn X Email