Count all elements until next element with same class name appears
<p>I need to get the number of all <code>windows-detail-spec-label</code> in between two <code>windows-detail-spec-group</code> classes in the folowing table layout - so I can use that number for rearanging the table on different screen sizes. </p>

<p>How can I count them so I get the correct number out? </p>

<p>For the first set of elements it should be <code>2</code> since <code>windows-detail-spec-label</code> appers twice inbetwen (note: next <code>windows-detail-spec-group</code> is in the second <code>.row-label</code> <code>tr</code>)</p>

<p><img src="http://i.stack.imgur.com/E47Ja.png" alt="table html layout"></p>

<p>My current code:</p>

<pre><code>$('.windows-details-spec-group').each(function () {

  var rowspanCount = $(this).nextUntil('.windows-details-spec-group').filter('.windows-details-spec-label').length;

  $(this).unwrap().next('tr.row-default').prepend(this);
  $(this).attr({
      colspan: 1,
      rowspan: rowspanCount  // need this variable to be correct
  });
});
</code></pre>

<p>So basically I need to count how many times a class appears between two elements <strong>no matter where in the DOM in between</strong>.</p>
