Answers for "onclick hide and show div in javascript"

0

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>
Posted by: Guest on July-13-2021
7

js hide div

//If you have jquery, you can use the following method:
$("#mydiv").hide(); //hides div.
$("#mydiv").show(); //shows div.
//If you don't have jquery...
//search up the following: html how to add jquery
Posted by: Guest on June-22-2020
0

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>
Posted by: Guest on July-16-2021
1

onclick show div and hide other div

<div id="1">A DIV element...</div>
<div id="2">Another DIV element</div>
<div id="3">The third DIV element</div>
<div id="4" onclick="hide()">Click me to hide the other DIVs</div>
<script type="text/javascript">
function hide() {
	document.getElementById("1").hidden = true;
	document.getElementById("2").hidden = true;
	document.getElementById("3").hidden = true;
	document.getElementById("4").hidden = false;
}
</script>
Posted by: Guest on September-01-2021
-2

javascript hide show div

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("#hide").click(function(){
    $("#1").hide();
    $("#2").show();
  });
  $("#show").click(function(){
    $("#1").show();
    $("#2").hide();
  });
});
</script>
</head>
<body>

<p id="1">Area 1</p>
<p id="2" style="display: none;">Second area</p>

<button id="show">Area 1</button>
<button id="hide">Second Area</button>

</body>
</html>
Posted by: Guest on February-01-2021
-1

hide and show div using javascript with example

hide and show divs using javascript
Posted by: Guest on July-07-2021

Code answers related to "onclick hide and show div in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language