Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dollar Sign Newbie Confusion

Status
Not open for further replies.

grahama1970

Technical User
Jan 24, 2004
9
US
In the function below, there is a dollar sign in front of a javascript property.
Why is a dollar sign needed in this case?

Excerpt from below function:
elem.$oldDisplay=curDisplay;

In this case, no Javascript libraries (like Prototype) are being accessed.



many thanks as I am still a newbie.




//The function from John Resig

//Afunction for hiding (using display) an element
function hide( elem ) {
//Findoutwhatitscurrentdisplaystateis
var curDisplay = getStyle( elem, 'display' );
// Remember its display state for later
if ( curDisplay != 'none' )
elem.$oldDisplay=curDisplay;

//Setthedisplaytonone (hiding the element)
elem.style.display = 'none';
}
//Afunction for showing (using display) an element
function show( elem ) {
//Setthedisplaypropertybacktowhatitusetobe,oruse
//'block',ifnopreviousdisplayhadbeensaved
elem.style.display = elem.$oldDisplay || '';
} CHAPTER 7 ?JAVASCRIPT AND CSS 151
7273ch07final.qxd 11/16/06 8:15 AM Page 151
 
It could simply be a convention of the author. Variable and property names in JS can begin with a $, AFAIK (well, at least they seem fine when I test it in Fx 1.5).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top