[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/API/Element/getElementsByTagName [Back]  [Original]

Element.getElementsByTagName() - Web API | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Element.getElementsByTagName()

Baseline
Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

Element.getElementsByTagName() (tag name) HTML . , , . live , DOM . , Element.getElementsByTagName() .

HTML HTML , getElementsByTagName . , SVG HTML Element.getElementsByTagNameNS() .

Element.getElementsByTagName Document.getElementsByTagName() .

In this article

js
elements = element.getElementsByTagName(tagName);
  • elements is a live HTMLCollection of found elements in the order they appear in the sub-tree. If no elements were found, the HTMLCollection is empty.
  • live HTMLCollection .
  • element is the element from where the search should start. Note that only the descendants of this element are included in the search, but not the element itself.
  • . .
  • tagName is the qualified name to look for. The special string "*" represents all elements. For compatibility with XHTML, lower-case should be used.
  • tagName . "*" . XHTML , .

Example

js
// check the alignment on a number of cells in a table.
var table = document.getElementById("forecast-table");
var cells = table.getElementsByTagName("td");
for (var i = 0; i < cells.length; i++) {
  var status = cells[i].getAttribute("data-status");
  if (status == "open") {
    // grab the data
  }
}

Specifications

Specification
DOM
# dom-element-getelementsbytagname

Browser compatibility


Web Proxy Viewer  |  New URL  |  Original Page