title: Wrapping a set of DOM elements using JavaScript
body: <p>I have a series of <code>p</code> tags on my page and I want to wrap them all into a container, e.g. </p>
  
  <pre><code>&lt;p&gt;foo&lt;/p&gt;
  &lt;p&gt;bar&lt;/p&gt;
  &lt;p&gt;baz&lt;/p&gt;
  </code></pre>
  
  <p>I want to wrap all the above tags into a container as follows:</p>
  
  <pre><code>&lt;div&gt;
      &lt;p&gt;foo&lt;/p&gt;
      &lt;p&gt;bar&lt;/p&gt;
      &lt;p&gt;baz&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>How to wrap a <code>NodeList</code> in an element using vanilla JavaScript?</p>