title: javascript toggle doesn't work on first press
body: <p><strong>The issue is in the title.</strong><br />
  I have been trying to fix this for 2 hours now, mostly just googling fixes, but I can't seem to find any that work. So now I'm here.</p>
  <p>Anyhow, I have a problem with a javascript toggle that I made.</p>
  <p><strong>What I'm trying to do:</strong><br />
  <em>Create an expand/collapse button that only expands/collapses a box when you click the arrow</em></p>
  <p>Here's the HTML;</p>
  <pre><code>&lt;a id=&quot;expand1&quot; value=&quot;OFF&quot; type=&quot;button&quot; class=&quot;btn btn-link collapsed&quot; onclick=&quot;toggle(this)&quot;&gt;
      &lt;div class=&quot;right&quot;&gt;
          &lt;i id=&quot;arrow&quot; class=&quot;animate-icon fa fa-solid fa-angle-up&quot;&gt;&lt;/i&gt; 
      &lt;/div&gt;
  &lt;/a&gt;
  
  &lt;div id=&quot;answer1&quot;&gt;
      answer
  &lt;/div&gt;
  </code></pre>
  <p>here's the JS;</p>
  <pre><code>function toggle(button) {
                  if (button.value == &quot;OFF&quot;) {
                      button.value = &quot;ON&quot;;
                      document.getElementById('answer1').style.opacity = &quot;1&quot;;
                      document.getElementById('answer1').style.height = &quot;350px&quot;;
                  }
                  else {
                      button.value = &quot;OFF&quot;;
                      document.getElementById('answer1').style.opacity = &quot;0&quot;;
                      document.getElementById('answer1').style.height = &quot;0px&quot;;
  
                  }
              }
  </code></pre>
  <p>What I've tried so far;</p>
  <ul>
  <li>Searching google for answers</li>
  <li>Searching stackoverflow for answers</li>
  <li>Defining &quot;<strong>on</strong>&quot; or &quot;<strong>off</strong>&quot; as a variable and using that as a toggle</li>
  <li>trying {if ([variable].style.height == &quot;350px&quot;) {}} (I have no idea if this would work or not, just thought I'd try it.)</li>
  </ul>
  <p>If anybody has any idea how to fix this, I would appreciate it very much if you were to tell me what I'm able to do to fix this problem. Thanks!</p>