Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVictor Ngo
8,324 PointsWhat's the difference between this and $this? Isn't the former sufficient to select the object of the method?
I can't seem to see the difference between <em>$(this)</em> and <em>this</em>. Wouldn't just <em>this</em> be enough to target the method's object even if the object is a jQuery element?
2 Answers
Kevin Korte
28,149 PointsThis the below stack overflow thread answer your question?
http://stackoverflow.com/questions/1051782/jquery-this-vs-this
Codye Watson
16,835 PointsGreat question Victor. I learned from this question as well.
Victor Ngo
8,324 PointsVictor Ngo
8,324 PointsAh I've found that this specific comment in the thread you've provided helped me understand this.
*$() is the jQuery constructor function.
this is a reference to the DOM element of invocation.
so basically, in $(this), you are just passing the this in $() as a parameter so that you could call jQuery methods and functions.*