Created
November 14, 2011 20:58
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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