this and $(this) refers to the same element. The only difference is the way they are used. ‘this’ is used in traditional sense, when ‘this’ is wrapped in $() then it becomes a jQuery object, and you are able to use the power of jQuery.

Check below examples for this and $(this) understanding:

$(document).ready(function(){
 $('#spnValue').mouseover(function()
{ 
alert($(this).text()); 
}); 
});

//And

$(document).ready(function(){ 
$('#spnValue').mouseover(function()
{ 
alert(this.innerText); 
}); 
})

Check More on jQuery

Leave a Reply

Your email address will not be published. Required fields are marked *

Explore More

How to Center a Popup Window on Screen

JavaScript window.open() method is used to open a popup window. This popup window will be placed in the center of the screen. This example creates the pop-up window without placing it into

How to hide URL in the popup window opened using window.open

If you are using below code to open a popup window in your web page, then address must be appearing in you pop up window and f you want to

window.showModalDialog is deprecated in Edge and Chrome

If you have a website being compatible with Edge/Chrome and in past it was only compatible with IE 11 and if you are using window.showModalDailog in your JavaScript code, then