Alexandre Plennevaux schrieb:
> Shouldn't it be
> this.click(function(){ alert(this.attr("id");) });
>
>
No, this is messing up with "this" even more ;-)
Either:
$(this).click(function() {
alert(this.id);
});
Or:
$(this).click(function() {
alert($(this).attr("id"));
});
$(this).attr("id") doesn't make much sense of course, because it's the
same as this.id. But if for some reason you'd need something like this
I'd exploit the power of closures and avoid multiple creations of the
jQuery objects:
var $$ = $(this);
$$.click(function() {
alert($$.attr("id"));
});
I got into the habit to store $(this) in a variable named $$ whenever
required.
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/