Skip to content

Instantly share code, notes, and snippets.

@natedoesweb
Created November 19, 2012 19:49
Show Gist options
  • Select an option

  • Save natedoesweb/4113347 to your computer and use it in GitHub Desktop.

Select an option

Save natedoesweb/4113347 to your computer and use it in GitHub Desktop.
Small plugin to hide placeholder text on focus.
$.fn.betterPlacehold = function() {
$.each($(this), function(){
var text = $(this).attr('placeholder');
$(this).focusin(function(){
$(this).attr('placeholder','');
});
$(this).focusout(function(){
if ($(this).val() == '') {
$(this).attr('placeholder', text);
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment