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

Define all the ways to include jquery in a page?

851


differentiate between bind() vs live() vs delegate() methods in jquery.

872


How to validate email using jquery?

941


What is the difference between "#" and "." selector in JQuery?

983


Explain the difference between onload() and document.ready() function used in jquery?

839


Is jquery a w3c standard? : jquery mobile

914


What is the difference between $(window).load and $(document).ready function in jquery?

849


Explain cache paremeter of jquery ajax method?

893


Create a plugin that would add and remove a class on hover.

832


How do I pull a native DOM element from a jQuery object?

899


Can we include multiple version of jquery? : jquery mobile

797


What is a use of jquery filter?

884


How can jquery library be added to pages? Write a basic jquery code?

844


How to find all sibling elements after the current element using ?

871


Explain the difference between .empty() and .remove() ?

822