FruitBatInShade
10-08-2003, 09:00 AM
I'm trying to show/hide <DIV> tags in a javascript. The problem is that the tags that are hidden isn't correct. I guess it may be due to the child/parent relationship.
To replicate
Click on node1
Node 1 should hide Node1.1 but hides itself too!
Any ideas whats wrong?
<HTML>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
function Hide(node)
{
var oVDiv=document.getElementById(node);
if (oVDiv.style.display == 'none')
{
oVDiv.style.display = '';
}
else
{
oVDiv.style.display = 'none';
}
}
</SCRIPT>
<div id="Main"><Span style="WIDTH:200px;BORDER-TOP-STYLE: outset; BORDER-RIGHT-STYLE: outset; BORDER-LEFT-STYLE: outset; BACKGROUND-COLOR: #ccff66; BORDER-BOTTOM-STYLE: outset"> Top </Span>
<div ID='Root' onClick="Hide('X')">Root
<div id='X' onClick="Hide('Y')" style='LEFT:10px;position:relative'>Node 1
<div id='Y' style='LEFT:20px;position:relative'>Node 1.1</div>
</div>
</div>
</div>
</BODY>
</HTML>
To replicate
Click on node1
Node 1 should hide Node1.1 but hides itself too!
Any ideas whats wrong?
<HTML>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
function Hide(node)
{
var oVDiv=document.getElementById(node);
if (oVDiv.style.display == 'none')
{
oVDiv.style.display = '';
}
else
{
oVDiv.style.display = 'none';
}
}
</SCRIPT>
<div id="Main"><Span style="WIDTH:200px;BORDER-TOP-STYLE: outset; BORDER-RIGHT-STYLE: outset; BORDER-LEFT-STYLE: outset; BACKGROUND-COLOR: #ccff66; BORDER-BOTTOM-STYLE: outset"> Top </Span>
<div ID='Root' onClick="Hide('X')">Root
<div id='X' onClick="Hide('Y')" style='LEFT:10px;position:relative'>Node 1
<div id='Y' style='LEFT:20px;position:relative'>Node 1.1</div>
</div>
</div>
</div>
</BODY>
</HTML>