How to hide a parent div if an inner div has a certain class, with javascript
<p>Ok so say I have many divs. Some of the divs, the children have one class, other divs the children have a different class.</p>

<p>I want to hide only the divs which have a child with a certain class.</p>

<p>For example,</p>

<pre><code>&lt;div class="mainDiv"&gt;
    &lt;div class="kulkul"&gt;
        &lt;div class="childA"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;div class="mainDiv"&gt;
    &lt;div class="lalala"&gt;
        &lt;div class="childB"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;div class="mainDiv"&gt;
    &lt;div class="kulkul"&gt;
        &lt;div class="childA"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;div class="mainDiv"&gt;
    &lt;div class="lalala"&gt;
        &lt;div class="childA"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;div class="mainDiv"&gt;
    &lt;div class="kulkul"&gt;
        &lt;div class="childB"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;div class="mainDiv"&gt;
    &lt;div class="lalala"&gt;
        &lt;div class="childA"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Now above, let's say that I only want to hide the parent divs which have a child div with the class <code>.childB</code></p>

<p>This can't be done with CSS as far as I know (CSS3 anyway), because CSS doesn't allow you to style the parent div, only a child div. And the parent <code>.mainDiv</code> divs (the ones I want to hide) are all exactly the same.</p>

<p>So that leaves javascript.</p>

<p>Using the example above, how can I hide all the <code>.mainDiv</code> divs which contain a child div with the class <code>.childB</code>?</p>