javascript - .find doesn't work in jquery 1.4.2 and I can't figure out how to support it -
i can't figure out how write code backwards support jquery 1.4.2. perplexed trying support older library files.
var n = this; e(document).ready(function () { var r = e("body").find(n); r.attr("placeholder", t); r.val(t); n.focus(function () { e(this).val("") }).blur(function () { var r = e(n); if (r.val() == "") r.val(t) }) })
you're overcomplicating code. first, don't need use $(document).ready()
inside of plugin, can let developer using plugin take care of that. next, inside of plugin, this
jquery object containing selected elements. should iterate on them act on each 1 individually.
(function ($) { $.fn.labelfixer = function (t) { return this.each(function(){ var $this = $(this); $this.attr("placeholder",t); this.value = t; $this.focus(function(){ if (this.value == t) { this.value = ""; } }); $this.blur(function(){ if (this.value == "") { this.value = t; } }); }); }; })(jquery);
Comments
Post a Comment