How can I test if an ancestor of my HTML element has a CSS class?
<p>Given HTML code like so - </p>

<pre><code>&lt;div id="parent" class="foo"&gt;
  &lt;div id="child"&gt;
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>How can I write a test to see if the <code>child</code> element has the class <code>foo</code> applied? I tried:</p>

<pre><code>element
.children("#child") //successfully selects child
.hasClass("foo");   //false :(
</code></pre>