title: For each div that has li, add class
body: <p>I'm using jQuery to achieve the following:</p>
  <ul>
  <li>For each div with the same id, check to see if the div has any li elements. If it does, then add a specific class.</li>
  </ul>
  <p>The code below only works for one of the divs. What do I change so that it loops through all instances of div with the same id.</p>
  <pre><code>$('#general-block').each(function() {
     if ($('general-block:has(li)').length) {
        $('general-block').addClass('testing-block');
     }
  });
  
  // The class 'testing-block' should be added to the first two divs with the id 'general-block' as they have li elements.
  &lt;div id='general-block' class='block'&gt;
     &lt;ul&gt;
        &lt;li&gt;Test&lt;/li&gt;
        &lt;li&gt;Test&lt;/li&gt;
     &lt;/ul&gt;
  &lt;/div&gt;
  
  &lt;div id='general-block' class='block'&gt;
     &lt;ul&gt;
        &lt;li&gt;Test&lt;/li&gt;
        &lt;li&gt;Test&lt;/li&gt;
     &lt;/ul&gt;
  &lt;/div&gt;
  
  &lt;div id='general-block' class='block'&gt;
     &lt;p&gt;Class won't apply to the parent div&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>