Skip to content

Instantly share code, notes, and snippets.

@chrisnharvey
Created August 19, 2013 13:59
Show Gist options
  • Save chrisnharvey/6269460 to your computer and use it in GitHub Desktop.
Save chrisnharvey/6269460 to your computer and use it in GitHub Desktop.
Remove HTML5 placeholders on focus
$(function() {
// Remove placeholders on focus
$("input, textarea").focus(function() {
var placeholder = $(this).attr('placeholder');
if (placeholder !== '') {
$(this).attr('placeholder', '');
$(this).attr('data-placeholder', placeholder);
} else {
$(this).attr('placeholder', placeholder);
}
});
$('input, textarea').blur(function() {
var placeholder = $(this).attr('data-placeholder');
if (placeholder !== '') {
$(this).attr('placeholder', placeholder);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment