Karl Swedberg schrieb:
> On Oct 15, 2006, at 7:58 AM, Klaus Hartl wrote:
>
>> $('a.clickme').click(function() {
>> $(this).next('div').show();
>> this.blur();
>> });
>>
> Thanks a lot, Klaus! This works in my test. So, it's a matter of
> using the built-in JavaScript variable "this" instead of the jQuery
> object "$(this)", right?
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...
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/