Spoiler tag
Posted: Thu May 28, 2009 3:01 am
I'm trying to create a spoiler tag for my site, but I can't figure out the Javascript.
I have this html:
And this javascript:
Whenever I click the button to hide or show the spoiler...FF tells me that "this.parentNode.getElementById" is not a function. What am I missing? Is it easier just to generate a random ID and try to select it from the whole document?
I have this html:
Code: Select all
<div class='spoiler'>
<a href='javascript:void(0)' onclick='toggleView(this.parentNode.getElementById("goods"))'>Show / Hide Spoiler</a>
<div id='goods' style='display: none'>
\\1
</div>
</div>Code: Select all
function toggleView(node)
{
if(node.display == 'none')
{
node.style.display = '';
}
else
{
node.style.display = 'none';
}
}