Question: In jQuery, how would I descend as far as possible into the HTML tree?

For simplicity, I only have one path going downward. 

(related but bonus: how do I find the deepest element with multiple downward paths?)

```
<html>  
  <table id="table0">  
    <tr>  
      <td id="cell0">  
        <div class"simple">  I want to change this information </div>  
      </td>
    </tr>  
  </table>  
</html>

```

I want to change the innermost HTML of the cell named **cell0** but I don't necessarily know the names of all the classes inside. Is it possible to select this far without knowing these names?

Thanks much!

Answer: 
This question has a simple and good answer when for jQuery. However, I was looking for an elegant solution without it. Since `:has` is not supported in any browser yet, I came up with this one here.

```
Array.from( document.querySelectorAll( 'body *' ) )
  .filter( e => !e.children.length );

```
Very late to the party, but here's my generic solution.

```
var elements$ = $(':contains("your text")');
var result = elements$.filter((index, element) => 
        index === elements$.length || 
        ! $.contains(element, elements$.get(index+1))
    );

```

It's very fast and simple, because jQuery already does all the job for us. 

Notice that `elements$` is an ordered list of containers, where many contain the next one. Thus the innermost elements are the last element plus all the elements that don't contain the next one.