Javascript/jQuery variable

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

Javascript/jQuery variable

Postby Otto » Tue Dec 22, 2020 3:33 pm

Javascript/jQuery variable, what is the proper way to use a var?

$() creates a new jQuery object. If you save a jQuery object to a variable it is pointless to create another jQuery object from it, although it still works. You will often see people wrap variables that were previously created as jQuery objects in $() purely due to bad practice and either forgetting it's already an object...or not understanding what they just created in the first place

Perhaps you may have seen

Code: Select all  Expand view
var $nav = $('nav');

$nav.hide();


Using the $ prefix is a common practice to denote that the variable is a jQuery object for code readability mostly


https://stackoverflow.com/questions/197 ... -use-a-var
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 15 guests