Possible Duplicate:
Focus and blur jQuery events not bubbling
var default_input_value = null;
jQuery('body').on('focus focusout', 'input[type="text"]', function(event){
if(event.type === 'focus'){
default_input_value = jQuery(this).val();
jQuery(this).val('');
}else if(event.type === 'focusout')
if(jQuery(this).val().length === 0)
jQuery(this).val(default_input_value);
}
);
This code simply does not respond to the event.
P.S.
it is important that there would be input[type="text"], because jQuery focus also fires on checkbox in some situations….
Under
.on()jquery document, there is a description:The
focusandblurevents are specified by the W3C to not bubble, but jQuery defines cross-browserfocusinandfocusoutevents that do bubble. Whenfocusandblurare used to attach delegated event handlers, jQuery maps the names and delivers them asfocusinandfocusoutrespectively. For consistency and clarity, use the bubbling event type names.Hope this would be useful.
And you can try this code: