Question: Suppose I have this HTML:

```
<div class="SomeParent" id="BlueParent">
  <div>
     <div class="Test">test</div>
  <div>
</div>

```

The div of class `Test` is actually deeply nested in the `SomeParent` container. What's the **fastest** way to get the id of the `SomeParent` class of which Test is a descendant. Is the `.parent()` the best way to do it?

Thanks for your suggestions.

Answer: 
Perhaps

```
$('.Test').closest('.SomeParent').attr('id');

```

<http://api.jquery.com/closest/>

I don't know if it would be any faster or slower than thecodeparadox's solution, however.
If you already have the `<div.Test>` as a jQuery object then you could use `.closest()` rather than using `.parents()`. `.closest()` will stop once it hits the first occurrence of the selector you give it. `.parents()` on the other hand traverses up to the root of the dom and gives you back all found.