You don't even need to explicitly accumulate the result:
$.fn.attrs = function(key, val) { if (val != undefined) return this.attr(key, val); return $.map(this, function(a) { return $(a).attr(key); }); }; Danny malsup wrote: > > Good catch, Jörn! > >> You don't even need the explicit loop: >> >> jQuery.fn.attrs = function(key, val) { >> if (val != undefined) >> return this.attr(key, val); >> var a = []; >> this.each(function() { a.push($(this).attr(key)); }); >> return a; >> }; > > -- View this message in context: http://www.nabble.com/.attr%28%29-tf3673211s15494.html#a10269078 Sent from the JQuery mailing list archive at Nabble.com.