Hello, I'm trying to make so 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. Home functions:
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 changed visibility:
<div id = "showup" class = "form-row" style = "display: none">
Code
</div>
Thank you in advance!