getElementsBy
getElementsBy is a family of DOM methods used to retrieve groups of elements from a document. The methods share a common purpose: return a collection of elements that match a certain criterion. The most widely used are getElementsByTagName and getElementsByClassName, with additional forms on HTML documents or Element contexts such as getElementsByName and getElementsByTagNameNS for namespace-aware contexts.
getElementsByTagName(tagName) returns a live HTMLCollection of all descendant elements whose tag name matches the provided tag.
getElementsByClassName(classNames) returns a live HTMLCollection of elements that have all of the classes specified in the
getElementsByName(name) returns a NodeList of elements whose name attribute equals the given name. This is commonly
getElementsByTagNameNS(namespaceURI, localName) performs a tag-name-based search within a given namespace and returns a live collection of
Because these collections are live, changes to the document are reflected automatically. For many use cases,