title: jQuery wrap each class + class elements ( different classes )
body: <p>I'm trying to wrap each two elements close to each other containing the classes <code>black</code> and <code>blue</code> in a <code>&lt;div class="wrap"&gt;</code> across my page.</p>
  
  <p>I tried this, but it doesn't work as I need:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(".black, .blue").each(function() {
    $(this).next().hasClass('black').wrapAll('&lt;div class="wrap"&gt;&lt;/div&gt;')
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="col red"&gt;&lt;/div&gt;
  &lt;div class="col black"&gt;&lt;/div&gt;
  &lt;div class="col blue"&gt;&lt;/div&gt;
  &lt;div class="col red"&gt;&lt;/div&gt;
  &lt;div class="col white"&gt;&lt;/div&gt;
  &lt;div class="col yellow"&gt;&lt;/div&gt;
  &lt;div class="col red"&gt;&lt;/div&gt;
  &lt;div class="col black"&gt;&lt;/div&gt;
  &lt;div class="col bllue"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is my desired output:</p>
  
  <pre><code>&lt;div class="col red"&gt;&lt;/div&gt;
  
  &lt;div class="wrap"&gt;
      &lt;div class="col black"&gt;&lt;/div&gt;
      &lt;div class="col blue"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="col red"&gt;&lt;/div&gt;
  &lt;div class="col white"&gt;&lt;/div&gt;
  &lt;div class="col yellow"&gt;&lt;/div&gt;
  &lt;div class="col red"&gt;&lt;/div&gt;
  
  &lt;div class="wrap"&gt;
      &lt;div class="col black"&gt;&lt;/div&gt;
      &lt;div class="col blue"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>