Dylane2020 Dylane2020 -3 years ago 92
Javascript Question

Connecting buttons

Ok so I am trying to make a code where by clicking one button you hide a button and make another appear. All the buttons appear and work but I have no clue how to make button 3 and 4 be hidden until button one is clicked.

<input type="button" onclick="b()";>no</button>
<script>
function a() {
alert ("button 1")
}
function b() {
alert ("button 2")
}
</script>

<input type="button" onclick="c()";>button 3</button>
<input type="button" onclick="d()";>button 4</button>
<script>
function c() {
alert ("button 3")
}
function d() {
alert ("button 4")
}

Answer Source

function button1Clicked() {
  document.getElementById('3').classList.remove('hidden');
  document.getElementById('4').classList.remove('hidden');
}
.hidden {
  display: none;
}
<input type="button" id="1" value="Button 1" onclick="button1Clicked();" />
<input type="button" id="2" value="Button 2" />
<input type="button" id="3" class="hidden" value="Button 3" />
<input type="button" id="4" class="hidden" value="Button 4" />

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download