hide div on button click javascript
<style>
function hideDiv(){
var closedDiv = document.getElementById("closableDiv");
closedDiv.style.display = "none";
}
</style>
<button id="closableDiv" onClick="hideDiv()"> </button>
hide div on button click javascript
<style>
function hideDiv(){
var closedDiv = document.getElementById("closableDiv");
closedDiv.style.display = "none";
}
</style>
<button id="closableDiv" onClick="hideDiv()"> </button>
onclick hide div javascript
<script type="text/javascript">
function hide(id) {
document.getElementById(id).style.display = "none";
}
function show(id) {
document.getElementById(id).style.display = "";
}
</script>
<div id="div" onclick="hide('div')">
<p>Click to hide!</p>
</div>
onclick show div and hide other div
<div id="div1">A DIV element...</div>
<div id="div2">Another DIV element</div>
<div id="div3" hidden>A hidden DIV element</div>
<button onclick="switchHidden()">Click to hide visible DIVs and show hidden ones</button>
<script type="text/javascript">
function switchHidden() {
document.getElementById("div1").hidden = !document.getElementById("div1").hidden;
document.getElementById("div2").hidden = !document.getElementById("div2").hidden;
document.getElementById("div3").hidden = !document.getElementById("div3").hidden;
// alternatively you could do something like Array.prototype.forEach.call(document.getElementsByTagName("div"), div => div.hidden = !div.hidden);
}
</script>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us