When/why to prefix variables with "$" when using jQuery?

elclanrs picture elclanrs · Jun 2, 2011 · Viewed 39.1k times · Source

Possible Duplicate:
Why would a javascript variable start with a dollar sign?

I see people using the dollar sign in front of variables when using jQuery. Is there any reason behind this? I'm I missing something basic or is it just a common practice?

Answer

Scott Harwell picture Scott Harwell · Jun 2, 2011

It's a common reference to a jQuery wrapped object. It makes reading the code easier to know which variables are jQuery wrapped.

//Item has been "cached" for later use in the script as a jQuery object.
var $item = $(this);