Collezione tBodies da tavolo
Esempio
Scopri quanti elementi <tbody> ci sono in una tabella:
var x = document.getElementById("myTable").tBodies.length;
Il risultato di x sarà:
2
Altri esempi "Provalo da solo" di seguito.
Definizione e utilizzo
La raccolta tBodies restituisce una raccolta di tutti gli elementi <tbody> in una tabella.
Nota: gli elementi nella raccolta sono ordinati come appaiono nel codice sorgente.
Supporto browser
Collection | |||||
---|---|---|---|---|---|
tBodies | Yes | Yes | Yes | Yes | Yes |
Sintassi
tableObject.tBodies
Proprietà
Property | Description |
---|---|
length | Returns the number of <tbody> elements in the collection. Note: This property is read-only |
Metodi
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 |
Dettagli tecnici
Versione DOM: | Oggetto documento di livello principale 2 |
---|---|
Valore di ritorno: | Un oggetto HTMLCollection, che rappresenta tutti gli elementi <tbody> nell'elemento <table>. Gli elementi nella raccolta sono ordinati come appaiono nel codice sorgente |
Altri esempi
Esempio
[ indice ]
Avvisa innerHTML del primo elemento <tbody> (indice 0) nella tabella:
alert(document.getElementById("myTable").tBodies[0].innerHTML;
Esempio
articolo ( indice )
Avvisa innerHTML del primo elemento <tbody> (indice 0) nella tabella:
alert(document.getElementById("myTable").tBodies.item(0).innerHTML);
Esempio
namedItem( id )
Avvisa l'innerHTML dell'elemento <tbody> con id="myTBody" nella tabella:
alert(document.getElementById("myTable").tBodies.namedItem("myTBody").innerHTML);
Pagine correlate
Riferimento HTML: tag HTML <tbody>
❮ Oggetto tabella