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: 
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.
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")

```