Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$('[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