Why isn't getElementById() available on Elements?
The git blame
on https://github.com/w3c/dom’s master branch points to:
commit f71d7de304e1ee25573279157dd6ce1c2aa2c4f2
Author: Anne van Kesteren
AuthorDate: Tue Nov 26 13:53:41 2013 +0000
Commit: Anne van Kesteren <[email protected]>
CommitDate: Tue Nov 26 13:53:41 2013 +0000Remove getElementById from Element. https://www.w3.org/Bugs/Public/show_bug.cgi?id=23860
and the linked bug describes how jQuery 1.2.5 + 1.2.6 (1.2.x?) are affected:
jQuery 1.2.5 assumes that any node it found in the DOM that has a "getElementById" property is a Document node. See https://bugzilla.mozilla.org/show_bug.cgi?id=933193#c17
As others have said in the comments, element IDs are supposed to be unique. There would be no need to have a getElementById
method on an element.
According to MDN's article on getElementById
:
Because ID values must be unique throughout the entire document, there is no need for "local" versions of the function.
The same is also true of getElementsByName