web api instance method
Element: getElementsByTagNameNS() method
The Element.getElementsByTagNameNS() method returns a
live HTMLCollection of elements with the given tag name belonging to the
given namespace. It is similar to getElementsByTagNameNS, except
that its search is restricted to descendants of the specified element.
Syntax
getElementsByTagNameNS(namespaceURI, localName)
Parameters
namespaceURI- : The namespace URI of elements to look for (see
namespaceURIandnamespaceURI). For example, if you need to look for XHTML elements, use the XHTML namespace URI,http://www.w3.org/1999/xhtml.
- : The namespace URI of elements to look for (see
localName
Return value
A live HTMLCollection of found elements in the order they appear in the tree.
Examples
// Check the alignment on a number of cells in a table in an XHTML document.
const table = document.getElementById("forecast-table");
const cells = table.getElementsByTagNameNS(
"http://www.w3.org/1999/xhtml",
"td",
);
for (const cell of cells) {
const axis = cell.getAttribute("axis");
if (axis === "year") {
// Grab the data
}
}
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.