Table tBodies- collectie
Voorbeeld
Ontdek hoeveel <tbody>-elementen er in een tabel zitten:
var x = document.getElementById("myTable").tBodies.length;
Het resultaat van x zal zijn:
2
Meer "Probeer het zelf" voorbeelden hieronder.
Definitie en gebruik
De verzameling tBodies retourneert een verzameling van alle <tbody>-elementen in een tabel.
Opmerking: de elementen in de collectie worden gesorteerd zoals ze in de broncode worden weergegeven.
Browserondersteuning
Collection | |||||
---|---|---|---|---|---|
tBodies | Yes | Yes | Yes | Yes | Yes |
Syntaxis
tableObject.tBodies
Eigenschappen
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-versie: | Kernniveau 2 documentobject |
---|---|
Winstwaarde: | Een HTMLCollection-object, dat alle <tbody>-elementen in het <table>-element vertegenwoordigt. De elementen in de collectie worden gesorteerd zoals ze in de broncode voorkomen |
Meer voorbeelden
Voorbeeld
[ index ]
Waarschuw de innerHTML van het eerste <tbody>-element (index 0) in de tabel:
alert(document.getElementById("myTable").tBodies[0].innerHTML;
Voorbeeld
artikel( index )
Waarschuw de innerHTML van het eerste <tbody>-element (index 0) in de tabel:
alert(document.getElementById("myTable").tBodies.item(0).innerHTML);
Voorbeeld
genoemdItem( id )
Waarschuw de innerHTML van het <tbody>-element met id="myTBody" in de tabel:
alert(document.getElementById("myTable").tBodies.namedItem("myTBody").innerHTML);
Gerelateerde pagina's
HTML-referentie: HTML <tbody>-tag
❮ Tafelobject