Skip to content

Instantly share code, notes, and snippets.

@orhanveli
Created November 14, 2011 20:58
Show Gist options
  • Save orhanveli/1365139 to your computer and use it in GitHub Desktop.
Save orhanveli/1365139 to your computer and use it in GitHub Desktop.
jQuery info hints for text inputs (clear on focus, restore on blur if not changed)
(function ($) {
// HINTS FOR FORM INPUTS PLUG IN
$.fn.clearDefault = function () {
return this.each(function () {
var $this = $(this);
var default_value = $this.attr('title');
$this.val(default_value);
var id = $this.attr('id');
$this.focus(function () {
if ($(this).val() == default_value) $(this).val("");
});
$this.blur(function () {
if ($(this).val() == "") $(this).val(default_value);
});
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment