Return to Snippet

Revision: 28475
at July 8, 2010 17:30 by omerta83


Initial Code
jQuery('form')  
    .focusin(function(){  
        jQuery(this).addClass('focused');  
    });  
    .focusout(function(){  
        jQuery(this).removeClass('focused');  
    });  
  
//However, the preferred way to do this is using  
// .focus() and .blur()  
  
//For when an element loses it's focus use .blur()  
$('#target').blur(function() { 
  alert('Handler for .blur() called.'); 
}); 
 
//For when an element gains focus use .focus() 
$('#target').focus(function() { 
  alert('Handler for .focus() called.');  
});

Initial URL

                                

Initial Description

                                

Initial Title
How to perform action when element gains focus

Initial Tags
javascript, jquery

Initial Language
JavaScript