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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the methods used to provide effects?

914


Why we use chaining in jquery?

830


what is the use of param() method in jquery .

713


What programming language does jquery use?

810


Why content injected into a page is not enhanced? : jquery mobile

780


Which operating system is more compatible with jQuery?

900


What is the use of val() method in jquery?

865


Is jquery is json library file or a javascript?

803


What are the slow selectors in jquery? : jquery mobile

808


How does the jQuery pushStack function work?

886


How can events be prevented to work after an ajax request?

756


How can jquery be used in conjunction with another javascript library that also uses $ for naming?

805


What is the difference between the knockout and jquery?

812


What is a filter in jquery? Explain

842


What's next on the hitlist with jquery ui?

873