Answers for "hide show div"


how to show hide div in html javascript

<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
#myDIV {
  width: 100%;
  padding: 50px 0;
  text-align: center;
  background-color: lightblue;
  margin-top: 20px;

<p>Click the "Try it" button to toggle between hiding and showing the DIV element:</p>

<button onclick="myFunction()">Try it</button>

<div id="myDIV">
This is my DIV element.

<p><b>Note:</b> The element will not take up any space when the display property set to "none".</p>

function myFunction() {
  var x = document.getElementById("myDIV");
  if ( === "none") { = "block";
  } else { = "none";

Posted by: Guest on March-20-2020


<script type="text/javascript">
    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if( == 'block')
 = 'none';
 = 'block';
Posted by: Guest on April-30-2021

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

how to hide div in html

Posted by: Guest on November-09-2019

hide a div

<div id="main"> 
  <p> Hide/show this div </p>

('#main').hide(); //to hide

// 2nd way, by injecting css using jquery
$("#main").css("display", "none");
Posted by: Guest on July-17-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language