What\'s the easiest way to get the depth of an element in pure JavaScript or jQuery? By \"depth\" I mean how many elements deep is it nested, or how many ancestors does it h
Supposing you don't want to include body and html tag in the parents to count use:
$("#element").parents("*").not("body,html").size()
Online demo here: http://jsfiddle.net/zaJff/