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

Can we select a element having a specific class in jquery ?

802


How can we apply css in even childs of parent node using jquery library?

857


Explain the each() function?

825


What are the two types of CDNs?

952


With jquery ui 1.7 being released in the last few days, what do you see as the key parts of jquery ui 1.7? What are you most proud of out of that release?

884


How to debug jQuery?

937


Can JQuery Run on MAC or Linux instead of Windows?

822


Explain jquery filter?

1129


Suppose if you have a server control(asp.net server control, button) and on the click of button you want to call a jquery function, so tell me how you will call a jquery function without postback?

830


What are the advantages of using cdn?

803


How to run an event handler only once in jQuery?

870


Difference between find() and closest() in jquery?

819


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

733


Difference between prop() and attr()? : jQuery Mobile

795


Explain .delegate()? : jquery mobile

792