Craptacular... My code: <div style="border:1px inset gray;width:100%;"><div><input type="button" value="Spoiler" class="button" onclick="if (this.innerHTML == 'Hide Spoiler'){this.parentNode.parentNode.childNodes[1].style.display = 'none'; this.innerHTML = 'Show Spoiler';}else{this.parentNode.parentNode.childNodes[1].style.display = 'inline'; this.innerHTML = 'Hide Spoiler';}; "" /> Code (markup): That doesn't work in Firfox 2.x, any help would be appreciated. BP
It doesn't work for me in IE7 too, could you post a bit more of surrounding code, like example for a working spoiler text?
I don't understand what you need but here is an example of working script: <script language="JavaScript"> <!-- function spoilerClick(el){ if (el.parentNode.childNodes[1].innerHTML == 'Hide Spoiler'){ el.parentNode.childNodes[1].style.display = 'none'; el.parentNode.childNodes[1].innerHTML = 'Show Spoiler'; } else{ el.parentNode.childNodes[1].style.display = 'inline'; el.parentNode.childNodes[1].innerHTML = 'Hide Spoiler'; }; } //--> </script> <div style="border:1px inset gray;width:100%;"><div><input type="button" value="Spoiler" class="button" onclick="spoilerClick(this)" /><div></div></div></div> Code (markup):
<div id="spoiltext" style="display:none; border: 1px inset gray; width: 100%;"> Spoiler Text </div> <div> <input type="button" value="Show Spoiler" class="button" onclick="this.value = ((this.value == 'Show Spoiler') ? 'Hide Spoiler':'Show Spoiler'); document.getElementById('spoiltext').style.display = ((document.getElementById('spoiltext').style.display == 'none')? 'inline':'none');" /> </div> Code (markup):