Thanks for the response Mike. That "Getter methods like that generally return the value for the first matched element" doesn't make sense to me. Why? There's no need for this altered behavior. It breaks the jQuery model in my opinion. Unless I am missing something.
Everything else in jQuery operates on arrays. I guess I am looking for someone to explain WHY the 'getter' functions operate this way from a design perspective. ----- Original Message ---- From: Mike Alsup <[EMAIL PROTECTED]> To: jquery-en@googlegroups.com Sent: Monday, April 30, 2007 8:20:54 PM Subject: [jQuery] Re: .attr() That's just not what it does. Getter methods like that generally return the value for the first matched element. If you want a plugin to return all the values in an array you can write it like this (untested): jQuery.fn.attrs = function(key,val) { if (val != undefined) return this.each(function() { $(this).attr(key,val); }); var a = []; this.each(function() { a.push($(this).attr(key)); }); return a; }; And then call it like this: var arr = $('div').attrs("id"); Mike On 4/30/07, Ariel Jakobovits <[EMAIL PROTECTED]> wrote: > > I am looking for an explanation as to why .attr('id') executed on an array of > jQuery elements does not return an array of ids. >