0
I need the button to change color every time clicked, I used Focus but does not bring me the expected result, because after the button is clicked, the user needs to click another corner, so the background color back to normal.
<div class="container">
<div class="row">
<div class="col-sm">
<button type="button" class="btn btn-primary bot-click" id="E" onclick="botaoClicado(this.id)" value="Red">CASA FECHADA</button>
</div>
<div class="col-sm">
<button type="button" class="btn btn-primary bot-click" id="D" onclick="botaoClicado(this.id)" value="Red">ENDEREÇO NÃO LOCALIZADO</button>
</div>
<div class="col-sm">
<button type="button" class="btn btn-primary bot-click" id="G" onclick="botaoClicado(this.id)">CLIENTE REAGENDOU</button>
</div>
</div>
</div>
There are these buttons, and the user can click on a button, but he can change choice and click on another, that the color of the previous clicked should return to normal and the new clicked change color.
JS
var bot = window.idBotaoClicado
function botaoClicado(e) {
bot = e
document.querySelector('.bot-click').style.background = 'Red'
}
I made this code, but for some reason it always ends up getting the button clicked and also the first button.
The goal is to show when a button has been pressed, like a choice? If it is, why not use a
radio
?– Ricardo Pontual
I didn’t find it clear enough
– Victor Eyer
@Ricardopunctual yes, because I need it done without radio
– Maria
@VME what you don’t understand?
– Maria
Could inform the javascript used that did not work as it should?
– Victor Eyer