Skip to content

Instantly share code, notes, and snippets.

@Relequestual
Created September 5, 2012 10:46
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 Relequestual/3634893 to your computer and use it in GitHub Desktop.
Save Relequestual/3634893 to your computer and use it in GitHub Desktop.
Remove helper text when given focus and re-display helper text when loose focus and empty
$("input, textarea").focus(function(){
if ($(this).val() == $(this).attr("title")) {
$(this).val("");
}
}).blur(function () {
if ($(this).val() == "") {
$(this).val($(this).attr("title"));
}
});
@codeincontext
Copy link

Why not use the placeholder attribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment