<div id="header">
<h1>Title</h1>
<ul>
<li>lalala</li>
<li><a href="#">lol</a></li>
</ul>
</div>
var nav = document.getElementsBySelector('#header ul');
You always do, because it is an errorpaulsheff said:You usually get validation errors with multiple uses of the same id.
While the function's great, it's got limited scope. With just descendant and attribute support, what happens if you have more than one list element and you want to only want to access one particular list - which do you pick out of the array? Or what happens when you move that particular list to a different part of the page?robmiller said:Although don't feel obliged to litter your code with unnecessary IDs if you just want to access the elements via Javascript; instead, use something like Simon Willison's getElementsBySelector() to select the element(s) via a CSS selector.
Al Vallario said:You always do, because it is an error