DOM:element.getElementsByTagName
z Mozilla Developer Center, polskiego centrum programistów Mozilli.
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...
Spis treści |
[edytuj] Podsumowanie
Returns a list of elements with the given tag name. The subtree underneath the specified element is searched, excluding the element itself.
[edytuj] Składnia
elements = element.getElementsByTagName(tagName)
-
elementsis a liveNodeListof found elements in the order they appear in the subtree. -
elementis 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. -
tagNameis 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.
[edytuj] 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
}
}
[edytuj] Uwagi
element.getElementsByTagName is similar to document.getElementsByTagName, except that its search is restricted to those elements which are descendants of the specified element.