title: jQuery UI Slider change class for each value
body: <p>I have a jQuery UI Slider that has a range between 1-100. I want to change the class of a div for each value between 1-100. </p>
  
  <p>I know there is a more efficient JavaScript method to switch classes and go through the values. Is there a better method other than the else if statement?</p>
  
  <p>Any tips to make this more efficient appreciated.</p>
  
  <pre><code>$( '#slider-container' ).slider({
  min: 1,
  max: 100,
  slide: function( event, ui ) {
      if ((ui.value == 2)) { 
          $( ".number_100" ).toggleClass( 'number_102' );
      } else if ((ui.value == 3)) { 
          $( ".number_100" ).toggleClass( 'number_103' );
      }
  }
  });
  </code></pre>
  
  <p>or (but not sure how to find/remove last class added?)</p>
  
  <pre><code>&lt;div class="position_100 number_101"&gt;&lt;/div&gt;    
  
  $( '.position_100' ).removeClass().addClass((ui.value&lt;10) ? 'number_10'+ui.value : 'number_1'+ui.value);
  </code></pre>