title: Comparing attributes and deleting duplicates in multiple lists
body: <p>I'm trying to create a jQuery script that can filter out list items based off the <code>href</code> attributes within each list item. So, if an <code>href</code> in <code>listOne</code> equals an <code>href</code> in <code>listTwo</code>, I want to add a class to the <code>listTwo</code> <code>li</code> to remove it from the list.</p>
  
  
  
  <pre><code>&lt;ul id="listOne"&gt;
      &lt;li&gt;&lt;a href="somelink"&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="somelink"&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;ul id="listTwo"&gt;
      &lt;li&gt;&lt;a href="somelink"&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="somelink"&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Here's what I have so far in the script:</p>
  
  <pre class="lang-js prettyprint-override"><code>var listOneHref = $("#listOne li a").each(function(){$(this).attr("href")});
  
  var listTwoHref = $("#listTwo li a").each(function(){$(this).attr("title")});
  
  if (listTwoHref = listOneHref) {
      $("#listTwo ul li").addClass("hidden");
  }   else {
      $("#listTwo ul li").removeClass("hidden");
  }
  </code></pre>
  
  <p>The result of the above script is that the "hidden" class is added to every <code>li</code> in <code>listTwo</code>. It doesn't seem to <em>only</em> select the duplicated hrefs.</p>
  
  <p>How would I write it so the script only adds the "hidden" class to the <code>li</code>s with duplicated <code>href</code>'s from <code>listOne</code> inside them?</p>