What is the difference between jQuery "this" and JavaScript "this"?
<p>I am reading a jQuery book and sometimes I see the example like:</p>

<pre><code>$('img[alt]').each(function(){
  $(this).replaceWith('&lt;span&gt;' + $(this).attr('alt')+ '&lt;/span&gt;')
}
</code></pre>

<p>and sometimes I see examples like:</p>

<pre><code>$('*').attr('title', function(index, value) {
return value + 'I am element ' + index + ' and my name is ' + this.id);
});
</code></pre>

<p>so see sometimes it is <code>$(this)</code> and sometimes it is just <code>this</code></p>

<p>What's the difference? How do I know which one to use and when?</p>
