What is the difference between $(this) and this in jQuery ? Here are two different usage :
$(document).ready(function() {
$("#orderedlist").find("li").each(function(i) {
$(this).append( " BAM! " + i );
});
});
$(document).ready(function() {
// use this to reset several forms at once
$("#reset").click(function() {
$("form").each(function() {
this.reset();
});
});
});
The “this” variable refers (in such cases as the event handlers you’ve supplied) to a DOM element. Thus $(this) is a jQuery object containing just that one DOM element.
You should use plain “this” when the native DOM APIs suffice, and $(this) when you need the help of jQuery. Your second example is a good illustration; another might be when you just need the “id” or “name” of an element.