title: Why does it takes to click to apply my function?
body: <p>I'm trying to write a code that when you click the button it shows and when pressed again it hides images. I made that images <strong>display</strong> to <strong>none</strong> and I want it to change to <strong>block</strong> when pressed the button (so it shows the images).</p>
  
  <p>It works, but <strong><em>only when you click twice</em></strong>.
  What should I do to activate it on one click?</p>
  
  <p>HTML :</p>
  
  <pre><code>&lt;button id="categoryBtn" onclick="insta()"&gt;instagram users&lt;/button&gt;
  </code></pre>
  
  <p>javascript : </p>
  
  <pre><code>function insta() {
    var a = document.getElementById("instaBalas");
  
    if (a.style.display == "none") {
      a.style.display = "block";
    } else {
      a.style.display = "none";
    }
  }
  </code></pre>