Difference between this and $(this) and when I should use which?

Difference between this and $(this) and when I should use which?

Hello all,

I am confused about when to use this and when to use $(this).
It seems that $(this) is related to jQuery and this is related to jQuery, however, in both case I and case III, this is related to jQuery (if my understanding is correct).

Thank you


  1. $('li').each(function(index) {
  2.     alert(index + ': ' + $(this).text()); // case I
  3.   });
  1. $(document.body).click(function () {
  2.       $("div").each(function (i) {
  3.         if (this.style.color != "blue") { // case II
  4.           this.style.color = "blue";
  5.         } else {
  6.           this.style.color = "";
  7.         }
  8.       });
  9.     });
  1. (function($){
  2. $.fn.makeItBlue = function() {
  3. return this.css('color','blue'); // case III
  4. }
  5. })(jQuery);