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
___________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/