Created
April 21, 2011 14:34
-
-
Save brianburridge/934644 to your computer and use it in GitHub Desktop.
Clear default text when user selects the input field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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