How do you add a class to parents only if two separate child divs are present
<p>How do you add a class to parents only if two separate child divs are present?</p>

<p>The code here works if the two classes are present in a child</p>

<pre><code>$('.class1.class2').parents().addClass('newclass');

&lt;div class="parentdiv"&gt;
&lt;div class="class1 class2"&gt;        
&lt;/div&gt;
</code></pre>

<p></p>

<p>I am trying to add class to parentdiv only if class1 and class2 are children</p>

<pre><code>&lt;div class="parentdiv"&gt;
&lt;div class="class1"&gt;
&lt;/div&gt;
&lt;div class="someother"&gt;
&lt;/div&gt;
&lt;div class="class2"&gt;    
&lt;/div&gt;
</code></pre>

<p></p>