Quantcast
Channel: What is the reason for var $this = this - Stack Overflow
Browsing latest articles
Browse All 7 View Live

Answer by Shaun for What is the reason for var $this = this

In actuality jQuery is a wrapper around the JavaScript DOM, both enhancing and simplifying it. Very briefly JQuery selectors return JQuery Object/s i.e.var jQueryResults = $("article"); //Contains all...

View Article


Answer by Brent Rittenhouse for What is the reason for var $this = this

I do $this = $(this) because it seems that it would save the actual processing of that call every single time you want to use it.Also, for the 'magic 'this'' function that someone else mentioned. It is...

View Article


Answer by Matt Briggs for What is the reason for var $this = this

What everyone else said, also there is an idiom in jquery code to prefix jquery objects with $. don't know how popular it is any more, but used to see a lot of it.

View Article

Answer by josh.trow for What is the reason for var $this = this

It means nothing in this case (no pun intended). It would be more logical if the statement was var $this = $(this) since that would allow for all the nice jQuery functionality to be used.

View Article

Answer by pimvdb for What is the reason for var $this = this

Generally, this means a copy of this. The thing about this is that it changes within each function. Storing it this way, however, keeps $this from changing whereas this does change.jQuery heavily uses...

View Article


Answer by Justin Niessner for What is the reason for var $this = this

In this case, nothing. $this is just another variable declaration which has this assigned to it.Typically, I've seen this shortcut used by people using JavaScript libraries when wrapping this. For...

View Article

What is the reason for var $this = this

I'm not the best at jquery and I came across a var initialization that I don't know why the person who wrote the code did it this way.In the init for a plugin, we havethis.init = function(settings) {...

View Article
Browsing latest articles
Browse All 7 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>