Remove value from input with jQuery

This jQuery code removes the value of a input text type when the user clicks on the input.


$(document).ready(function(){
$('input:text').each(function() {
var label = $(this).val();
$(this).focus(function() {
if($(this).val() == label) {
$(this).val('');
}
});
$(this).blur(function() {
if($(this).val() == '') {
$(this).val(label);
}
});
});
});

This entry was posted in JavaScript. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.