Changed to classes
I'm now using this:
code:
<script>
function hide(id){
document.getElementById(id).style.display = 'none';
}
function show(id){
document.getElementById(id).style.display = '';
}
function spoilerhide(){
for (i=0;i<document.getElementsByTagName('div').length;i++) {
if (document.getElementsByTagName('div')[i].class == 'spoiler') {
document.getElementsByTagName('div')[i].style.color = '#000000';
}
}
}
function spoilershow(){
for (i=0;i<document.getElementsByTagName('div').length;i++) {
if (document.getElementsByTagName('div')[i].class == 'spoiler') {
document.getElementsByTagName('div')[i].style.color = '#FF0000';
}
}
}
</script>
<div id="div1">
<input type="button" onClick="hide('div1'); show('div2'); spoilershow();" value="Laat spoilers zien">
</div>
<div id="div2" style="display:none;">
<input type="button" onClick="show('div1'); hide('div2'); spoilerhide();" value="Verberg spoilers">
</div>
But it still doesn't work, and with
code:
if (document.getElementsByTagName('div')[i].class = 'spoiler')
instead of
code:
if (document.getElementsByTagName('div')[i].class == 'spoiler')
It makes all div's white and black