Answers for "div hide and show in javascript"

12

javascript hide div

// javascript
<script>
	document.getElementById("id").style.display = "none";  //hide
	document.getElementById("id").style.display = "block"; //show
	document.getElementById("id").style.display = ""; 	   //show
</script>

// html
<html>
	<div id="id" style="display:none">
    <div id="id" style="display:block">
</html>

// jquery
<script>
	$("#id").hide();      
	$("#id").show();
</script>
Posted by: Guest on May-18-2020
-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

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language