id
values must be unique in the document, so there's very little need to look for an element by id within another element. Just look for it on the document.
In the rare case you need to look for an element by id
only within another element's descendants, you can use querySelector
with an ID selector:
const e = someElement.querySelector("#the-id");
...but again, it's a rare use case that likely suggests that id
s are being misused.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…