title: Javascript:Toggle Function is not working
body: <p>I am trying to make a simple toggle but it is not working.And i want it done in javascript not in jquery.
  Here is my javascript.</p>
  
  <pre><code>&lt;script&gt;
  function showhide() {
  
      if (document.getElementById(ptag).style.display = "block") {
          document.getElementById(ptag).style.display = "none";
      } else {
          document.getElementById(ptag).style.display = "block";
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my HTML.</p>
  
  <pre><code>&lt;input type="button" value="Show hide" onclick="showhide()"&gt;
  &lt;p id="ptag"&gt;Some text here.&lt;/p&gt;
  </code></pre>
  
  <p>I need solution :(</p>