grahama1970
Technical User
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
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