title: Check mutiple div if contains specific text to add css class
body: <p>I got a page and want to add a css class to every heading, which contains a specific word above it, inside the div "metadata". Here is an example:</p>
  
  <pre><code>&lt;ul class="postlist"&gt;
  &lt;li&gt;&lt;div class="postBox"&gt;
  &lt;h2&gt;&lt;a href="http://sample.com"&gt; Test Sample 1&lt;/a&gt;&lt;/h2&gt;
  &lt;div class="metadata"&gt;&lt;a href="LinkToCat" class="link" id="cat"&gt;Internal, Test&lt;/div&gt;
  &lt;/div&gt;&lt;/li&gt;
  
  &lt;li&gt;&lt;div class="postBox"&gt;
  &lt;h2&gt;&lt;a href="http://sample.com"&gt; Test Sample 2&lt;/a&gt;&lt;/h2&gt;
  &lt;div class="metadata"&gt;&lt;a href="LinkToCat" class="link" id="cat"&gt;Test&lt;/div&gt;
  &lt;/div&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I tried with jquery like this:</p>
  
  <pre><code>if ($('div.postBox &gt; div.metadata &gt; a:contains("Internal")').length &gt; 0)
      $( "h2 a" ).addClass( "a-internal" );
  </code></pre>
  
  <p>This works - But the problem is, every heading element gets the class "a-internal", because the headings don't have unique IDs/names, right? Does somebody have an idea how I can nevertheless only add the class to the specific heading?</p>
  
  <p>Thanks a lot!</p>