element.getElementsByTagName

« Dokumentacja DOM

UWAGA: Tłumaczenie tej strony nie zostało zakończone.
Może być ona niekompletna lub wymagać korekty.
Chcesz pomóc? | Dokończ tłumaczenie | Sprawdź ortografię | Więcej takich stron+.

Podsumowanie

Returns a list of elements with the given tag name. The subtree underneath the specified element is searched, excluding the element itself.

Składnia

elements =element.getElementsByTagName(tagName) 
  • elements is a live NodeList of found elements in the order they appear in the subtree.
  • 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.

In Firefox 2 (Gecko 1.8.1) and earlier this method didn't work correctly if the subtree had elements with namespace prefix in the tag name (See błąd 206053 for details.)

It's recommended to use element.getElementsByTagNameNS when dealing with multi-namespace documents.

Przykład

// 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++) { 
    status = cells[i].getAttribute("status"); 
    if ( status == "open") { 
        // grab the data 
    }
}

Uwagi

element.getElementsByTagName is similar to document.getElementsByTagName, except that its search is restricted to those elements which are descendants of the specified element.

Specyfikacja

DOM Level 2 Core: Element.getElementsByTagName

 

 

Autorzy i etykiety dokumentu

Autorzy tej strony: splewako, Listek, Diablownik, Mgjbot
Ostatnia aktualizacja: splewako,