Is there a cheap method to select the deepest child of an element ?
Example:
<div id="SearchHere">
<div>
<div>
<div></div>
</div>
</div>
<div></div>
<div>
<div>
<div>
<div id="selectThis"></div>
</div>
</div>
</div>
<div>
<div></div>
</div>
</div>
EDIT: This is likely a better approach than my original answer:
Example: http://jsfiddle.net/patrick_dw/xN6d5/5/
or this which is even a little shorter:
Example: http://jsfiddle.net/patrick_dw/xN6d5/6/
Original answer:
This would seem to work:
Example: http://jsfiddle.net/xN6d5/4/
If you know that the deepest will be a certain tag (or something else), you could speed it up by replacing
.find('*')with.find('div')for example.EDIT: Updated to only check the length if the current element does not have a
firstChildor if it does, that the firstChild is not a type 1 node.