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.
You could use parents() rather than parent() to specify the class of the parent element that you are searching for within the DOM tree of parents.

```
$(".Test").parents(".SomeParent").attr("id")

```