title: How to change Visibility of Div
body: <p>I want to change visibility of DIV on pressing of button . whats wrong with this code 
      
      
        </p>
  
  <pre><code>     &lt;p id="myP"&gt;This is a p element.&lt;/p&gt;
  
       &lt;button type="button" onclick="myFunction()"&gt;Hide content of p&lt;/button&gt;
  
       &lt;script&gt;
          function myFunction() {
             var which= document.getElementById("myP");
  
            if (which.style.visibility=="visible")
                which.style.visibility = "hidden"
            else
                which.style.visibility = "visible"
          }
  
       &lt;/script&gt;
  
    &lt;/body&gt;
  </code></pre>
  
  <p></p>