Javascript JQuery var $varname is not a PHP variable!

JQuery

JQuery (Photo credit: Wikipedia)

Recently, I came across some JQuery code with a variable declaration having a $ sign before the variable name.

Below is an excerpt of the code.

var markup = "<p>" + category.description + "</p><ul data-role='listview' data-inset='true'>",
$header = $page.children( ":jqmData(role=header)" ),
markup += "</ul>";

After doing a brief search I found the following explanation very useful and this might take out the confusion that may have you screaming to yourself “Is JQuery now running PHP?”

“ It just seems to be common practice by a lot of jQuery people smarter than us to signify it’s a jQuery object stored in that variable, it has zero to do with jQuery itself per se”.

via [jQuery] var $varname – jQuery Forum.

Advertisements