Skip to content

Instantly share code, notes, and snippets.

@chuyeow
Created June 3, 2009 10:34
Show Gist options
  • Save chuyeow/122922 to your computer and use it in GitHub Desktop.
Save chuyeow/122922 to your computer and use it in GitHub Desktop.
// Clear newsletter textbox on focus if it contains the default text.
$('#newsletter_email').focus(function() {
var value = $(this).val();
// Clear the textbox if it's the default value.
if (!$(this).data('default') || value == $(this).data('default')) {
$(this).data('default', value);
$(this).val('');
}
}).blur(function() {
if ($(this).val() == '') {
$(this).val($(this).data('default'));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment