Since the identifiers are unique, you should use document.getElementById, as this is the only DOM element that has this feature.
Elements other than documenthave the following functions: getElementsByTagName, getElementsByClassName, querySelectorand querySelectorAll, but not getElementById.
Why not define it on elements other than the document?
. , , . , getElementById , document.
?
<div> <p> .cls, . , document , , , .
:
document.getElementById , DOM ( ). , getElementsByTagName, getElementByClassName,... , . , , , .