$()
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.
http://www.learningjquery.com/2007/08/what-is-this
good figures: http://jsperf.com/jquery-this-vs-this-vs-chain/2
You usually use var $this = $(this);
to avoid creating a new jQuery object more often than necessary. In case of the code below you only create one object instead of two/four. It is completely unrelated to chainability.
this
in javascript (usually) represents a reference to the object that invoked the current function.
Generally the purpose of storing $(this)
in a local variable is to prevent you from calling the jQuery function $()
multiple times, caching a jQueryized this
should help efficiency if you have to use it multiple times.
$
is simply a valid variable name character and is used as the first character of a variable name usually to queue the programmer that it is a jQuery object already (and has the associated methods/properties available).
$this vs $(this) in jQuery