How to determine which level on dom is selected

I have the following selector

$ ('# navigation ul li a'). click (function (evt) {}

this is to get the elements I need, and also repeat the child elements.

those. i get it too

#navigation ul li li a  // extra li

It’s just interesting to know what level of dom I choose.

+3
source share
1 answer

you can use which is a selector parent > child..

see Choosing a child ("parent> child")

you could use it something like this

$('#navigation>ul>li>a')
+3
source

Source: https://habr.com/ru/post/1729818/


All Articles