I have a button in my project, which the function is to make appear a div that is like display none, however the function is only executed from the second click on the button, the first click just selects the button. Would anyone know to tell me what I'm doing wrong?
Follow prints:
Screen:
Button:
Firstclick:(Selectedbutton)
Secondclick:(Divappears)
Code:
HTML:
<buttonclass="btn botaoGlobalLeft" ng-click="$ctrl.intermediacao()">
<span class="glyphicon glyphicon-menu-down"></span> Intermediação</button>
<div class="elemento form-group row" id="intermediacao">
<div class="row">
<div class="col-sm-2">
<label for="apelido2">Apelido</label>
<input type="text" title="Informe o apelido" id="apelido2" class="form-control inputEstoque">
</div>
</div>
CSS:
#informacoes{
display: none;
}
JS (Angular):
intermediacao() {
const display = document.getElementById("intermediacao").style.display;
if (display == "none") {
document.getElementById("intermediacao").style.display = 'block';
} else {
document.getElementById("intermediacao").style.display = 'none';
}
}