title: collapse element in javascript not just hide it?
body: <p>I'm not using css I have an html form with a bunch of div classes and inputs and it loads a .js which I'm using to capture the input and do the various things with the data.</p>
  <pre><code>&lt;div class=&quot;input01&quot;&gt;
   &lt;label for=&quot;i_01_txtb1&quot;&gt;&lt;b&gt;Txt Box 1:&lt;/b&gt;&lt;/label&gt;
   &lt;input type=&quot;text&quot; name=&quot;i_01_txtb1&quot; id=&quot;i_01_txtb1&quot;/&gt;
  &lt;/div&gt;
  &lt;div class=&quot;input02&quot;&gt;
  &lt;div class=&quot;input03&quot;&gt;
  </code></pre>
  <p>and so on up to 10. inside each div class is x amount of text inputs.
  each one also has a button at the start. When the buutton is pressed it hides or shows the div class of inputs.</p>
  <p>Basically if you only need one, fill in the first set and submit. Otherwise click the button to show the next set and fill it in and submit, so you submit 2. If you need more... on and on.</p>
  <p>All are hidden except input01 on start.</p>
  <p>Everything above works exactly as described, except if the user only wants the first two inputs, the last 8 are hidden, but they have to scroll past the 8 invisible sets to get to the submit button.</p>
  <p>I want the hidden elements to be collapsed, but I can't seem to find a collapsed state of elements. Is there such a thing?</p>
  <p>snippet of code looks like this:</p>
  <pre><code>var div_input02 = document.querySelectorAll('.input02')
  </code></pre>
  <p>function to toggle visibility of items in div class</p>
  <pre><code>    // function to hide / show all elements in a div class
          function toggleVisClass(div_class) {
              if (div_class[0].style.visibility != 'hidden') {
                  for (let el of div_class) el.style.visibility = 'hidden';
              } else {
                  for (let el of div_class) el.style.visibility = 'visible';
              }
            };
  </code></pre>
  <p>on click of the button to toggle visibility:</p>
  <pre><code>        // on click show input 02
          $(&quot;#i_02_expand&quot;).click(function() {
              toggleVisClass(div_input02)
              toggleVis(btn_i_03)
          });
  </code></pre>
  <p>As stated, the above works but the page is still super long as even though all the non-desired inputs are invisible, they still take up layout space which i don't want when hidden.</p>
  <p>thanks!</p>