Please tell me how to make sure that by clicking on the image, all other images are hidden. By pressing again, they were shown back.
All blocks have one class. I tried through the cycle, but did not work
function selectimage(item) { var arr = document.getElementsByClassName("image"); for (var i = 0; i < arr.length; i++) { if (arr[i].style.display = "block") arr[i].style.display = "none"; else arr[i].style.display = "block"; } item.style.display = ""; } <div class="image" id="mount" onclick="selectimage(this)"> <img src="img/1.jpg" alt="image"> </div> <div class="image" id="forest" onclick="selectimage(this)"> <img src="img/2.jpg" alt="image"> </div> <div class="image" id="see" onclick="selectimage(this)"> <img src="img/3.jpg" alt="image"> </div>
if (arr[i].style.display == "block")- Alexey Shimansky