title: jQuery nextAll with class value increment
body: <p>I was hoping someone could help be out here. I have a stack of divs with classes '.my-div-1', '.my-div-2', '.my-div-3' etc. I have a button inside each div that when clicked, removes this div. What I'd like to do from there is update all proceeding div classes. So if I deleted div with class '.my-div-2' the next div in line, '.my-div-3', would become '.my-div-2', the next after that, '.my-div-4', would become '.my-div-3' and so on.</p>
  
  <p>The way I have it set up now, is that I use .nextAll() to remove the old class and add the new, with a dymanic updating number. However, this only works for the next one, and the dynamic number doesn't incrament for the later divs. I am not sure that nextAll is the way to do this or not, there might be a better way. Any ideas on how to achieve this? Any help would be appreciated.</p>
  
  <p>EDIT - I should also mention that each div also has a mix of other classes that I need to preserve as well.</p>
  
  <p>The HTML is:</p>
  
  <pre><code>&lt;div class="my-div-container"&gt;
     &lt;div class="myDiv my-div-1"&gt;&lt;/div&gt;
     &lt;div class="myDiv my-div-2"&gt;&lt;/div&gt;
     &lt;div class="myDiv my-div-3"&gt;&lt;/div&gt;
     &lt;div class="myDiv my-div-4"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and the jQuery in a click event:</p>
  
  <pre><code>var divIndex = $(this).parents('.myDiv').prevAll().length;      
  
  $(this).parents('.myDiv').nextAll().removeClass('my-div-'+(divIndex+1)).addClass('my-div-'+(divIndex));
  $(this).parents('.myDiv').remove();
  </code></pre>