Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daifu/2119138 to your computer and use it in GitHub Desktop.
Save daifu/2119138 to your computer and use it in GitHub Desktop.
$.fn.html5_placeholder = function() {
var input = $(this);
input.focus(function() {
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
input.val(input.attr('placeholder'));
}
}).blur();
}
.placeholder {
color: #aaa;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment