0
Hi, I’m trying to make sure that when the button is clicked, change the visibility of a div and the icon changes.
If I remove the part that refers to the icons, the visibility is changed normally, but with the whole code, nothing happens.
function:
function changeVisibility() {
var display = document.getElementById("showup").style.display;
if (document.getElementById("icon").classList.contains('fa fa-angle-down')){
document.getElementById("icon").classList.toggle('fa fa-angle-up')
}else if (document.getElementById("icon").classList.contains('fa fa-angle-up')){
document.getElementById("icon").classList.toggle('fa fa-angle-down')
}
if(display == "none"){
document.getElementById("showup").style.display = 'block';
}else{
document.getElementById("showup").style.display = 'none';
}
}
button:
<button onclick = "changeVisibility()" class = "btn btn-success btn-md">
<span id = "icon" class = "fa fa-angle-down"></span>
</button>
div that has altered visibility:
<div id = "showup" class = "form-row" style = "display: none">
Code
</div>
Thank you in advance!
I get it, I’ll test it when I get home. Thank you very much!
– Tales Igor
It worked, thank you very much man :)
– Tales Igor