title: How can I compare a live element to one stored in data?
body: <p>I have a series of divs:</p>
  
  <pre><code>&lt;div class="some_class active"&gt;Some Content&lt;/div&gt;
  &lt;div class="some_class"&gt;Different Content&lt;/div&gt;
  &lt;div class="some_class"&gt;More Different Content&lt;/div&gt;
  </code></pre>
  
  <p>(active class changes dynamically) </p>
  
  <p>Each has been assigned to data of an image element thusly:</p>
  
  <pre><code>$("div.some_class").each(function(){
          current = $(this);
  
          $('div#images').append('&lt;img class="link new" src="/style/images/image.png" /&gt;');
          $(".link.new").removeClass('new').data('project', current);
      });
  </code></pre>
  
  <p>I want to use this function to compare the active element to those stored in data:</p>
  
  <pre><code>function live_test(){
  
          active = $("div.some_class.active");
          $("#images img.link").each(function(){
  
              if ($(this).data('project') == active){
                  $(this).addClass("active");
              }
          });
      }
  </code></pre>
  
  <p>The intention being to add a class of <code>active</code> to the image that holds the same <code>div.some_element</code> as the one that has the active class, but this function returns false all the time, never finding a match. I am pretty sure I am missing a fundamental here, but what? And is there any other way to do it?</p>