[jQuery] Re: Referring to the current DOM object in a jQuery method parameter list

2009-12-31 Thread Šime Vidas
This should do the job: $("#someid").each(function() { $(this).text($(this).attr("alt")); }); It is longer and more unreadable than your original code $("#someId").text($("#someId").attr("alt")); but you do get rid of redundancy = you do not have to write the same selector twice, which is gener

[jQuery] Re: Referring to the current DOM object in a jQuery method parameter list

2009-12-31 Thread Scott Sauyet
On Dec 31, 1:19 pm, Nathan Klatt wrote: > But, that seems like too much code for jQuery. :) I want something > like: > > $someId.text(self.attr("alt")); I've often wanted something like that too. Unfortunately... > This doesn't work: > > $someId.text($(this).attr("alt")); > > Does that function