Tabelle tBodies- Sammlung
Beispiel
Finden Sie heraus, wie viele <tbody>-Elemente eine Tabelle enthält:
var x = document.getElementById("myTable").tBodies.length;
Das Ergebnis von x ist:
2
Weitere „Probieren Sie es selbst“-Beispiele weiter unten.
Definition und Verwendung
Die tBodies-Sammlung gibt eine Sammlung aller <tbody>-Elemente in einer Tabelle zurück.
Hinweis: Die Elemente in der Sammlung werden so sortiert, wie sie im Quellcode erscheinen.
Browser-Unterstützung
Collection | |||||
---|---|---|---|---|---|
tBodies | Yes | Yes | Yes | Yes | Yes |
Syntax
tableObject.tBodies
Eigenschaften
Property | Description |
---|---|
length | Returns the number of <tbody> elements in the collection. Note: This property is read-only |
Methoden
Method | Description |
---|---|
[index] | Returns the <tbody> element from the collection with the specified index (starts at 0). Note: Returns null if the index number is out of range |
item(index) | Returns the <tbody> element from the collection with the specified index (starts at 0). Note: Returns null if the index number is out of range |
namedItem(id) | Returns the <tbody> element from the collection with the specified id. Note: Returns null if the id does not exist |
Technische Details
DOM-Version: | Dokumentobjekt der Kernebene 2 |
---|---|
Rückgabewert: | Ein HTMLCollection-Objekt, das alle <tbody>-Elemente im <table>-Element darstellt. Die Elemente in der Sammlung werden so sortiert, wie sie im Quellcode erscheinen |
Mehr Beispiele
Beispiel
[ Inhaltsverzeichnis ]
Benachrichtigen Sie das innerHTML des ersten <tbody>-Elements (Index 0) in der Tabelle:
alert(document.getElementById("myTable").tBodies[0].innerHTML;
Beispiel
Artikel ( Index )
Benachrichtigen Sie das innerHTML des ersten <tbody>-Elements (Index 0) in der Tabelle:
alert(document.getElementById("myTable").tBodies.item(0).innerHTML);
Beispiel
NamedItem( id )
Benachrichtigen Sie das innerHTML des <tbody>-Elements mit id="myTBody" in der Tabelle:
alert(document.getElementById("myTable").tBodies.namedItem("myTBody").innerHTML);
Verwandte Seiten
HTML-Referenz: HTML-<tbody>-Tag
❮ Tabellenobjekt