For example, in my theme, I have the following elements,
<ul>
<li> apple </li>
<li> orange </li>
<li> banana </li>
<li> pear </li>
<li> peach </li>
...
</ul>
I just want to display the first two li elements, how to hide the other ones form the third element?
The given condition to my issue is that, I cannot add any attribute like id or class to li elements.
For example, in my theme, I have the following elements,
<ul>
<li> apple </li>
<li> orange </li>
<li> banana </li>
<li> pear </li>
<li> peach </li>
...
</ul>
I just want to display the first two li elements, how to hide the other ones form the third element?
The given condition to my issue is that, I cannot add any attribute like id or class to li elements.
Share Improve this question asked Oct 29, 2018 at 17:13 p onelandp oneland 171 silver badge8 bronze badges1 Answer
Reset to default 0You can css
ul li:nth-child(n+3) {
display: none;
}
It'll not show 3rd and up.