title: JQuery for loop - function with variables
body: <p>Is there a way to turn this into a for loop? I have to run this code 114 time and am looking for a way to simplify this. The numbers on the class name would be the variable. The next one would be .select3 etc...</p>
  
  <pre><code>$('.select2').click(function () {
          if ($('.saved_list .thumb2').length == 0 &amp;&amp; $('.saved &gt; li').length &lt; totalPic)
              {
                  $(this).parent().clone().appendTo('.saved_list ul');
                  $('.saved .select2').replaceWith('&lt;div class="remove2"&gt;Remove&lt;/div&gt;');
                  $('.saved a').contents().unwrap(); 
              } else {
                  alert ('You can only choose 3 paintings');  
              }
              if ($('.saved_list li').has('.thumb2')) {
                  $(".select2 .img-swap").attr("src", "images/check_on.gif");
              } else {
                  $(".select2 .img-swap").attr("src", "images/check_off.gif");
          };
      });
  </code></pre>