Skip to content

Instantly share code, notes, and snippets.

@galengidman
Last active December 10, 2015 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galengidman/4438742 to your computer and use it in GitHub Desktop.
Save galengidman/4438742 to your computer and use it in GitHub Desktop.
Snippet for data-placeholder powered input and textarea placeholders.
$('[data-placeholder]').focus(function() {
if ($(this).val() == $(this).attr('data-placeholder')) {
$(this).removeClass('inactive');
$(this).val('');
}
});
$('[data-placeholder]').blur(function() {
if ($(this).val() == '') {
$(this).addClass('inactive');
$(this).val($(this).attr('data-placeholder'));
}
});
$('[data-placeholder]').blur();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment