I\'ve seen some discussions on SO regarding $(this)
vs $this
in jQuery, and they make sense to me. (See discussion here for an example.)
Bu
$this
is just a local copy of this
wrapped in jQuery.
In the long term, keeping a local copy rather than wrapping this
each time it is needed is much more efficient.
$this
is just an ordinary variable. The $
character is a valid character in variable names, so $this
acts the same as any other non-reserved variable name. It's functionally identical to calling a variable JellyBean
.
$this
is simply a local variable, named that way to remind you of $(this)
. It saves the work of creating the jQuery version of this
, and you can use it a number of times.
$
sign is usually used before variable names in JavaScript to differentiate between general value and jQuery object. So here $this
just gets the value of $(this)
which returns jQuery object of this
. $
is just a part of valid variable name.
It just fills $this
variable with $(this)
, so you do not have to lookup for $(this)
element every call. It has better performance
var $this = $(this);
$this
is a variable named $this
containing a reference to $(this)
. A bit pointless IMO.