When I click on the cancel button, I hide the Edit div and then show the Info div. The first condition works:
function main() { var info = document.getElementById("Info"); var edit = document.getElementById("Edit"); var edit_button = document.getElementById("Edit_button"); if (getComputedStyle(info).display == "none" && getComputedStyle(edit).display == "block") { edit.style.display = "none"; info.style.display = "block"; edit_button.style.display = "block"; alert("INFO" + info.style.display + " Edit" + edit.style.display + "Edit_Button" + edit_button.style.display); } if (getComputedStyle(edit).display == "none" && getComputedStyle(info).display == "block") { info.style.display = "none"; edit_button.style.display = "none"; edit.style.display = "block"; } } #Info { display: block; } #Edit { display: none; } #Edit_button { display: block; } <div id="Info"> .... </div> <input type="button" value="Edit" id="Edit_button" onclick="main()"> <div id="Edit"> <form name="Edit_form" method="POST" onsubmit=""> ... <input type="button" value="Cancel" onclick="main()" class="Button"> </div> BUT! The edit div remains (must hide), and the info div does not appear.

main()when you press any button? Naturally, both conditions are checked on both buttons in order from top to bottom. In the first condition, you doedit.style.display = "none"andinfo.style.display = "block", after which the second condition is checked further down the code - and according to previous changes, it turns out to be true. In your code there is nothing between the first and the second condition that would prevent the second condition from working - andreymal