title: match cookie with element ID using each()
body: <p>I have a bunch of cookies set that I want to match against the IDs of all elements on the page. Essentially, on page load iterate through dom and check if this element's ID value matches a cookie's value and do something to that element.</p>
  
  <p>Here is my code so far.</p>
  
  <pre><code>&lt;div class="event" id="event_1"&gt;
  
  &lt;/div&gt;
  
  &lt;div class="event" id="event_100"&gt;
  
  &lt;/div&gt;
  
  &lt;div class="event" id="event_47"&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Assume there are cookies already set:</p>
  
  <pre><code>event_1, event_1, 30
  event_100, event_100, 30 
  event_47, event_47, 30
  </code></pre>
  
  <pre class="lang-javascript prettyprint-override"><code>$('.event').each(function() {
      var id = $(this).attr('id');
      if (id == readCookie('event_'+id+'')) {
          $(this).hide();
      }
  
      console.log(id);
      //returns event_1,event_100,event_47
  });
  </code></pre>
  
  <p>I think I'm almost there. I think it has something to do with the var id and it returning a array. If I hard-code it to event_1 it works. </p>
  
  <p>What should I be doing here? Thanks</p>