docs.rodeo

MDN Web Docs mirror

Element: getElementsByTagNameNS() method

{{APIRef("DOM")}} 

The Element.getElementsByTagNameNS() method returns a live {{domxref("HTMLCollection")}}  of elements with the given tag name belonging to the given namespace. It is similar to {{Domxref("Document.getElementsByTagNameNS")}} , except that its search is restricted to descendants of the specified element.

Syntax

getElementsByTagNameNS(namespaceURI, localName)

Parameters

Return value

A live {{domxref("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

{{Specifications}} 

Browser compatibility

{{Compat}} 

In this article

View on MDN