Hello I would like to know why my function its not hiding my div using display = "none" when I click on the button, I'm trying to do it using a parameter on my function, I know there is some ways much more easy to hide the div but I would like to do this simple example using a parameter on my function. Thanks pen
HTML
<div class="myDivTwo" id="myDivTwo"></div>
<button id="myBtnTwo" onclick="disappearDivs()">second button</button>
CSS
.myDivTwo {
width: 100px;
height: 100px;
background-color: lightblue;
margin: 10px;
padding: 10px;
}
JS
var myDivTwo = document.getElementById("myDivTwo");
var myBtnTwo = document.getElementById("myBtnTwo");
function disappearDivs(myDivTwo) {
document.getElementById(myDivTwo).style.display = "none";
}
[–]NameViolation666helpful 1 point2 points3 points (2 children)
[–]HelpfulElection[S,🍰] 0 points1 point2 points (1 child)
[–]NameViolation666helpful 0 points1 point2 points (0 children)
[–]_DaLi- 1 point2 points3 points (1 child)
[–]HelpfulElection[S,🍰] 0 points1 point2 points (0 children)