2
I have a menu with up to 3 levels of nested lists. I need to select only the first level text and skip the nested content. I tried to use .menu > ul> li {}
(and some variations of this) and did not result in what needed.
I tried to use .menu li:first-child > ul
and resulted in the opposite of what I need, ie brought everything but the first level. I tried to use the pseudo-seletor :not
in the above condition but could not.
So I need help with this selector. How to do?
<div class="menu">
<ul>
<li>Item nível 1
<ul>
<li>Item nível 2
<ul>
<li>Item nível 3</li>
<li>Item nível 3</li>
<li>Item nível 3</li>
</ul>
</li>
<li>Item nível 2</li>
<li>Item nível 2</li>
</ul>
</li>
<li>Item nível 1
<ul>
<li>Item nível 2</li>
<li>Item nível 2</li>
<li>Item nível 2</li>
</ul>
</li>
</ul>
</div>
Can you put your code so far in CODEPEN or JSFIDDLE? It will be easier to understand what you would like to do. ( I’m confused ).
– concas
The first example should have worked, unless your HTML is not in the structure I’m thinking of. It would be better if you put an example, just as the friend above said.
– Thiago Yoithi
@Thiagoyoith put the html to make clear how the structure is. In reality the ultimate goal is to take the texts that in the example are "Item level 1" and ignore the rest, using jquery. But the bottleneck is on this dial that I’m not hitting. Thank you.
– GuilhermeD
@Guilhermed, post your code exactly, here or in Jsfiddle, Codepen... Please.
– Diego Souza
@Gumball the code is this of the topic, no more. They are nested lists. How to select only the text of the 1st level. In the example, how to select "Item level 1" texts. Grateful.
– GuilhermeD
Why not just put a specific class for these guys?
– Kenny Rafael