Possible Duplicate:
jQuery $(this) vs this
What is the difference between “this” and “$(this)”?
How do I know which one to use?
Related, I think:
With each, you have the optional parameters.
How is the “i” different than “this” (or “$(this)”)?
$('img').each(function(i) { ....code }
vs.
$('img').each(function() { ....code }
the
thisobject doesn’t change. It is the owner of the function. It is, in most cases like this, simply a node and you can reference all of its properties likethis.className. (think of it as you would a node or whatnot that you get withdocument.getElementById). It is just the “owner” of the function.Therefore, you are just passing the
thisobject to jQuery’s$().Conclusion: If you want to use jQuery functions for the current node, use
$(this). But if you want to access the objects own properties (e.g..name,className,.id), use simplythis.