There are 3 buttons on my custom page called page.php
:
<input type="submit" value="Btn 1" id="btn1">
<input type="submit" value="Btn 2" id="btn2" onClick="action();>
<input type="submit" value="Btn 3" id="btn3" onClick="action();>
The first button Btn 1
is initially hidden upon loading:
document.getElementById('btn1').style.visibility = 'hidden';
When either Btn 2
or Btn 3
is clicked, the goal is to hide that specific button and show Btn 1
:
var hidden = false;
function action() {
hidden = !hidden;
if(hidden) {
document.getElementById('btn1').style.visibility = 'visible';
document.getElementById('btn2').style.visibility = 'hidden';
document.getElementById('btn3').style.visibility = 'hidden';
}
}
This method results in an empty space when Btn 1
was visible. Placing it below Btn 2
and Btn 3
leaves two empty spaces in their original positions.
Is there a way to show and hide these buttons in the same place on an html
page?