<p>I'd like to check ancestry using two jQuery objects. They don't have IDs, and are only going to be available as jQuery objects (or DOM nodes if you called <code>get()</code>). jQuery's  <code>is()</code> only works with expressions, so this code would be ideal but will not work:</p>

<pre><code>var someDiv = $('#div');

$('a').click(function() {
    if ($(this).parents().is(someDiv)) {
        alert('boo');
    }
}
</code></pre>

<p>Just want to see if one element is a child of another and I'd like to avoid stepping back into DOM land if possible.</p>

You can use the index() method to check if an element exists in a list, so would the following work?
```
```
var someDiv = $('#div');

$('a').click(function() {
    if ($(this).parents().index(someDiv) >= 0) {
        alert('boo');
    }
}
```
```
From
#index reference
.