i’m not sure but if i understood right js nextSibling focus next node ? So why i get trouble, when i want to select ul in a li ?
<ul>
<li><input id="btn-page" type=button onclick="displayMenu();" /></li>
<ul class="hide">
<li>Some text</li>
</ul>
<li>...</li>
</ul>
And my js function :
function displayMenu() {
var idMenu = event.target.id;
var ulDisplay = document.getElementById(idMenu).nextSibling;
ulDisplay.style.display = 'block';
}
I think i forgot something but i don’t know why. Thanks for help 🙂
As @andreas pointed out the structure of your HTML is not valid because you can’t have a UL as child of a UL. But you can have a UL as a child of LI. So consider updating your HTML in this way. Helper function “Next()” from previous similar answer Hide an element's next sibling with Javascript used to find the UL