Karl Swedberg schrieb: > On Oct 15, 2006, at 11:51 AM, Klaus Hartl wrote: > >> Yes, the keyword this refers to the <a> element and you call the >> build-in method blur on it. >> >> Consider the following: >> >> $('a').blur(function() { >> this.blur(); >> }); >> >> $('a.clickme').click(function() { >> $(this).next('div').show(); >> $(this).blur(); >> >> // or in one chain: $(this).blur().next('div').show(); >> >> }); >> >> That also works because you attached a blur event to all <a> elements >> first and now can trigger it by $(this).blur(). >> >> That may make more sense. Say there comes a point you want to >> remove the >> blur on links. Instead of having to edit this.blur() all over the >> place >> you can simply edit it in one place: >> >> $('a').blur(function() { >> //this.blur(); >> }); >> >> Same if you want to enhance the blur event... >> >> $('a').blur(function() { >> this.blur(); >> >> // add something here >> }); >> >> Edit one line and you are done. Just a thought of mine... > > Yes, and an excellent thought it was. Really appreciate the extra > suggestion. Mind if I write something up in learningjquery.com about > this? I'll give you credit, of course, for the "thought." > > Cheers, > Karl
Go for it. Maybe it wasn't that excellent :-) One could simply write: $('a').click(function { this.blur(); }); That way it should work identically and you don't have to pollute other handler functions with $(this).blur() ... The only difference is that you loose control here a bit over when blur() is called in comparison with the other approach. -- Klaus _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/