If I have this list of elements, and I want to hide only the first one, with CSS it would be like this:
li{
background: yellow;
border: 1px solid;
margin: 10px;
display: block;
}
li:first-child {
display: none;
}
<li><a href="#">PRIMERO</a></li>
<li><a href="#">SEGUNDO</a></li>
<li><a href="#">TERCERO</a></li>
The problem occurs when the list is dynamic: it could be 0, 1, 2 or more elements, in my front I don't have how to count them.
li{
background: yellow;
border: 1px solid;
margin: 10px;
display: block;
}
li:first-child {
display: none;
}
<li><a href="#">UNICO</a></li>
How do I manage to create a CSS conditional with javascript? Only apply first:child if there is more than 1 element, otherwise the display would be block.