cells collection
The elements in the collection are sorted in source code order.
Syntax:
The base interface, through which you can add new functionalities to the cells collections, is the HTMLCollection interface.
Possible members:
Properties:
Returns an integer that specifies the number of elements in the current collection.
This property is read-only. |
Methods:
[nameOrIndex] |
Returns an element or a collection of elements from the current collection by name or index.
Parameters:
Return value:
In Firefox, if more than one match is found, the first matching element is returned.
|
||||||||||||||||||||||
item (nameOrIndex [, subIndex]) |
Returns an element or a collection of elements from the current collection by name or index.
Parameters:
Return value:
|
||||||||||||||||||||||
namedItem (name) |
Returns an element or a collection of elements from the current collection by name.
Parameters:
Return value:
|
||||||||||||||||||||||
tags | Returns a NodeList collection that contains all elements from the current collection with the specified tag name. | ||||||||||||||||||||||
urns | Returns a NodeList collection that contains all elements to which the specified behavior is attached. |
Example HTML code 1:
This example illustrates the use of the cells collection:
|
||||
<head> <script type="text/javascript"> function GetCells () { var message = ""; var table = document.getElementById ("myTable"); for (var i = 0; i < table.rows.length; i++) { var row = table.rows[i]; for (var j = 0; j < row.cells.length; j++) { var cell = row.cells[j]; message += i + ". row " + j + ". cell: " + cell.innerHTML + "\n"; } } alert (message); } </script> </head> <body> <table id="myTable" border="1px"> <tbody> <tr> <td>First row, first cell.</td> <td>First row, second cell.</td> </tr> <tr> <td>Second row, first cell.</td> <td>Second row, second cell.</td> </tr> </tbody> </table> <br /><br /> <button onclick="GetCells ();">Get the contents of the cells!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
External links:
User Contributed Comments