$.fn.extend = function(obj) { return this.each(function() { for (var prop in obj) this[prop] = obj[prop]; }); }; $.fn.collect = function(func) { var r = []; this.each(function(i) { r.push(func.apply(this, [i])); }); return r; }; $.fn.select = function(func) { var r = []; this.each(function(i) { if (func.apply(this, [i])) r.push(this); }); return r; }; $.fn.first = function() { return $(this.get(0)); }; $.fn.last = function() { return $(this.get(this.size() - 1)); }; $.fn.pluck = function(prop) { return this.collect(function() { return this[prop]; }); };