I want javascript to recognize which button to press, when you press button A to show div A, and when you press button B show div B, the two divs may not appear together.
The code I'm currently doing is like this:
<input type="button" id="A" required="" value="A" onclick="Mudarestado()"/>
<input type="button" id="B" required="" value="B" onclick="Mudarestado()"/>
<div class="row" id="displayA" style="display:none;">
<p>A</p>
</div>
<div class="row" id="displayB" style="display:none;">
<p>B</p>
</div>
</div>
<script>
function Mudarestado(el) {
var btn // deve receber o valor do botão A ou do botao B
console.log(btn);
if (btn == "A"{
var display = document.getElementById('displayA').style.display;
if(display == "none")
document.getElementById('displayA').style.display = 'block';
else
document.getElementById('displayA').style.display = 'none';
} if else ( btn == "B" ){
var display = document.getElementById('displayB').style.display;
if(display == "none")
document.getElementById('displayB').style.display = 'block';
else
document.getElementById('displayB').style.display = 'none';
}
}
</script>