/ Published in: JavaScript
Expand |
Embed | Plain Text
(function($){ $.fn.defaultValue = function() { var args = arguments; var c = 0; return this.each(function() { var el = $(this); var def = args[c++]; el.val(def).focus(function() { if (el.val() == def) { el.val(""); } }).blur(function() { if (el.val().replace(/\s+/, "") == "") { el.val(def); } }); }); }; })(jQuery); $(document).ready(function() { $('#name').defaultValue("asdf"); });
You need to login to post a comment.
