Skip to content

Instantly share code, notes, and snippets.

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 xbb/863882 to your computer and use it in GitHub Desktop.
Save xbb/863882 to your computer and use it in GitHub Desktop.
$('[placeholder]').focus(function() {
var input = $(this);
if (input.hasClass('placeholder')) {
input.val('')
.removeClass('placeholder')
.attr('autocomplete', 'on');
}
}).blur(function() {
var input = $(this);
if (input.val().length === 0) {
input.addClass('placeholder')
.val(input.attr('placeholder'))
.attr('autocomplete', 'off');
}
}).blur()
.parents('form').submit(function() {
$(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.hasClass('placeholder')) input.val('');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment