R
Rostov
I've got a script where I'm trying to toggle the visibility of a div
node by a click on an image that is the sibling of the div.
So I've got this HTML:
<div>
<img src="RightPointingTriangle.gif" onclick="openclose(this);">
<span class="title">title</span>
<div class="contents">
Hi. This is the contents.
</div>
<div class="children">
</div>
</div>
And this javascript:
function openclose(imgemt)
{
if(imgemt.src.indexOf("RightPointingTriangle.gif") > -1)
{
imgemt.src = "DownRightPointingTriangle.gif";
imgemt.src = "DownPointingTriangle.gif";
parent = imgemt.parentNode;
//find the parent of the image element
contents = parent.childNodes[2];
//get the child of that element that is a
//div with the class contents
//alert("contents :" + properties(contents));
contents.style.visibility = 'visible';
}
else
{
imgemt.src = "DownRightPointingTriangle.gif";
imgemt.src = "RightPointingTriangle.gif";
parent = imgemt.parentNode;
//find the parent of the image element
contents = parent.childNodes[2];
//get the child of that element that
//is a div with the class contents
alert("contents :" + contents);
contents.style.visibility = 'hidden';
}
}
The problem I'm seeing seems to be that when I try to set
contents.style.visibility to 'visible' or 'hidden', I get
the following error:
Error: contents.style has no properties
Source File: http://weston.canncentral.org/misc/sheesh/test.html
Line: 16
Why would this be the case, and how could I fix it?
The test page is viewable on the net, by the way, at:
http://weston.canncentral.org/misc/sheesh/test.html
node by a click on an image that is the sibling of the div.
So I've got this HTML:
<div>
<img src="RightPointingTriangle.gif" onclick="openclose(this);">
<span class="title">title</span>
<div class="contents">
Hi. This is the contents.
</div>
<div class="children">
</div>
</div>
And this javascript:
function openclose(imgemt)
{
if(imgemt.src.indexOf("RightPointingTriangle.gif") > -1)
{
imgemt.src = "DownRightPointingTriangle.gif";
imgemt.src = "DownPointingTriangle.gif";
parent = imgemt.parentNode;
//find the parent of the image element
contents = parent.childNodes[2];
//get the child of that element that is a
//div with the class contents
//alert("contents :" + properties(contents));
contents.style.visibility = 'visible';
}
else
{
imgemt.src = "DownRightPointingTriangle.gif";
imgemt.src = "RightPointingTriangle.gif";
parent = imgemt.parentNode;
//find the parent of the image element
contents = parent.childNodes[2];
//get the child of that element that
//is a div with the class contents
alert("contents :" + contents);
contents.style.visibility = 'hidden';
}
}
The problem I'm seeing seems to be that when I try to set
contents.style.visibility to 'visible' or 'hidden', I get
the following error:
Error: contents.style has no properties
Source File: http://weston.canncentral.org/misc/sheesh/test.html
Line: 16
Why would this be the case, and how could I fix it?
The test page is viewable on the net, by the way, at:
http://weston.canncentral.org/misc/sheesh/test.html