There is such a small code for feedback and I'm confused with it. the question is how, when pressed, hide where you clicked and open another block (which is already working). And just do the opposite, clicking on the second block (hiding) that would open the first.

<a onclick="onclickVhod();" id="idExid"class="popup_toggle"> <div class="circlephone" style="transform-origin: center;"></div> <div class="circle-fill" style="transform-origin: center;"></div> <div class="img-circle" style="transform-origin: center;"> <div class="img-circleblock" style="transform-origin: center;"></div></div> </a> <span onclick="onclickExid()" id="idVhod" ><span id="ugcontcal"></span></span> <script> var idVhod = document.getElementById('idVhod'); function onclickVhod() { idVhod.style.display = (idVhod.style.display == 'inline') ? '' : 'inline'; localStorage.setItem('hide', idVhod.style.display); // сохраняем значение в ключ hide } if(localStorage.getItem('hide') == 'inline') { // если значение ключа hide "inline" document.getElementById('idVhod').style.display = 'inline'; } var idExid = document.getElementById('idExid'); function onclickExid() { idExid.style.display = (idExid.style.display == 'none') ? '' : 'none'; localStorage.setItem('hide', idExid.style.display); // сохраняем значение в ключ hide } if(localStorage.getItem('hide') == 'none') { // если значение ключа hide "none" document.getElementById('idExid').style.display = 'none'; } </script> 

http://jsfiddle.net/ryb4uexf/3/

  • Be sure to save in localstorage If the page is reloaded, then you will still have to check the current value in localstorage - ZIBER MINSK
  • @ZIBERMINSK and it should be - AndSol

2 answers 2

See how it is implemented by me, maybe it will give an idea. When you click on the button, it calls the function changeDiv, passing a parameter (your ID) - which lets you know where you click, well, and accordingly you can find out what you did NOT click on and change what you need.

The default element style is display: none. (the one that should initially be hidden)

<button id="idHere" onclick="changeDiv(this.id)">Button</button>

 function changeDiv(divID) { var ifclosed = document.getElementById(divID).style.display; if (ifclosed==='' || ifclosed==='none') { document.getElementById(divID).style.display = "block"; // show body div tag } else { document.getElementById(divID).style.display = "none"; // hide body div tag } } 
     <script> var idVhod = document.getElementById('idVhod'); var idExid = document.getElementById('idExid'); idExid.style.display = localStorage.getItem('idExid'); idVhod.style.display = localStorage.getItem('idExid') == 'none' ? 'inline' : 'none'; function onClickThis(){ if(localStorage.getItem('idExid') == 'none'){ localStorage.setItem('idExid','inline'); idVhod.style.display = 'none'; idExid.style.display = 'inline'; } else{ localStorage.setItem('idExid','none'); idVhod.style.display = 'inline'; idExid.style.display = 'none'; } } </script>