JS/jQuery: Get depth of element?

后端 未结 6 2140
面向向阳花
面向向阳花 2020-12-29 07:21

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

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 07:55

    Try something like this:

    
        
            MooExample
            
            
        
    
        
            
    • moo
    • foo
    • fasoo
    • moasf
    • moosadg
    • moo1
    • moo412
    • moo613a

提交回复
热议问题