Skip to content

Instantly share code, notes, and snippets.

@brianburridge
Created April 21, 2011 14:34
Show Gist options
  • Save brianburridge/934644 to your computer and use it in GitHub Desktop.
Save brianburridge/934644 to your computer and use it in GitHub Desktop.
Clear default text when user selects the input field
$('input[data-default]').select(function () {
if ($(this).val() == $(this).attr('data-default')) {
$(this).val('');
}
});
$('input[data-default]').click(function () {
if ($(this).val() == $(this).attr('data-default')) {
$(this).val('');
}
});
$('input[data-default]').blur(function () {
if ($(this).val() == '') {
$(this).val($(this).attr('data-default'));
}
});
$('input[data-default]').each(function(index) {
if ($(this).val() == '') {
$(this).val($(this).attr('data-default'));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment