Skip to content

Instantly share code, notes, and snippets.

@ssskip
Created March 19, 2014 08:15
Show Gist options
  • Save ssskip/9637456 to your computer and use it in GitHub Desktop.
Save ssskip/9637456 to your computer and use it in GitHub Desktop.
jQuery placeholder
(function($) {
var t = function() {
};
"placeholder" in document.createElement("input") || (t = function() {
var t = $(this), n = t.attr("placeholder");
n && (t.focus(function() {
this.value === n && (this.value = ""), t.removeClass("placeholder");
}).blur(function() {
this.value === "" && (this.value = n, t.addClass("placeholder"));
}), t.val() === "" && t.addClass("placeholder"), t.val() || t.val(n));
}), $.fn.placeholder = t;
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment