Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Difference between $(this) and 'this' in jQuery?



Difference between $(this) and 'this' in jQuery?..

Answer / chaitanya

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.

Hide Copy Code

$(document).ready(function(){

$('#spnValue').mouseover(function(){

alert($(this).text());

});

});

In below example, this is an object but since it is not wrapped in $(), we can't use jQuery method and use the native JavaScript to get the value of span element.

Hide Copy Code

$(document).ready(function(){

$('#spnValue').mouseover(function(){

alert(this.innerText);

});

});

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More jQuery Interview Questions

Can you please explain the difference between parent() and parents() methods in jquery? : jquery mobile

0 Answers  


Explain the difference between jquery-x.x.x.js and jquery.x.x.x min.js?

0 Answers  


Explain .on()? : jquery mobile

0 Answers  


Is there any difference between body onload() and document.ready() function?

1 Answers  


How to divide a page into parts using jquery mobile? : jquery mobile

0 Answers  


What are selectors in jQuery and how many types of selectors are there?

1 Answers  


What are the methods used to provide effects in jquery?

0 Answers  


What is the difference between jquery.size() and jquery.length?

1 Answers  


What does dollar sign mean in jquery? : jQuery Mobile

0 Answers  


Explain the script build up by jquery?

0 Answers  


What is the use of jQuery.data() method?

0 Answers  


Write the code to define a requirejs module with its dependencies.

0 Answers  


Categories