<script type="text/javascript">
var appel = document.getElementById("appel");
var Banaan = document.getElementById("Banaan");
var Peer = document.getElementById("Peer");
function laatZien(divID) {
var item = document.getElementById(divID);
if (item.className == "verstopt") {
item.className = "zichtbaar";
} else {
item.className = "verstopt";
}
if (divID == "appel") {
alert("hoi");
Peer.className = "verstopt";
Banaan.className = "verstopt";
}
}
</script>
On my page i have 3 pictures with 3 buttons, and when one of the buttons is pressed, one picture must appear, but the others must go away.
The id's of these pictures are: "appel", "Peer", "Banaan".
When the pictures get the class "zichtbaar" -> display: block;
and when they get the class "verstopt" -> display:none;
The first if/else
statement works fine: it hides when it is shown, and it shows when it is hidden.
but even though the second if-statement does get triggered(i have tested this), the other pictures dont get hidden.(pictures Peer and Banaan)
And yes i know that i still have to do the last if statement 3x for each picture ;)
` tag.
– adeneo Feb 13 '16 at 19:33