title: Using Jquery .addClass on html elements in array
body: <p>I have a few html image tags that fill an array. On the page - <a href="http://www.digitalbrent.com/lab" rel="nofollow">http://www.digitalbrent.com/lab</a> - three of the elements in the array are displayed. I need to add a class to them after a button is clicked. The class is different for each if the imgs being displayed from the array. Here's the code:</p>
  
  <pre><code>$(document).ready(function(){        //populates array with images
  
      var shipImgs = $("#thumb_slider").children();
      console.log(shipImgs);
  
      $.each(shipImgs,function(i,elem){
          var tag = "&lt;img src='" + $(elem).attr('src') + "' alt='space'/&gt;"; // This is how I made the image tags.
          imgArr.push(tag);
      });
      console.log(imgArr);
  
  });
  
  $("#basic_ul").html(imgArr[b] + imgArr[a] + imgArr[c]); //displays the images
          imgArr[b].addClass("left_slot");
          imgArr[a].addClass("middle_slot");
          imgArr[c].addClass("right_slot");
  </code></pre>
  
  <p>I've also tried it with the selector around the array items, $(imgArr[b]).addClass("left_slot"); but that didn't work either.</p>
  
  <p>Any advice at all would be greatly appreciated. I've looked through similar questions here on stackoverflow but no luck. I've been researching this project for a while now and can't find anything.</p>