Difference between this and $(this)

$(this) is a jQuery object and you can use the power and beauty of jQuery, but with this keyword, one need to use native JavaScript.

e.g. I want display text of an span element on mouse over.

$(‘#spnValue’).mouseover(function(){
alert($(this).text()); //with $
alert(this.innerText()); //without $
});

Leave a comment