You are here: Reference > JavaScript > client-side > HTML DOM > properties > cellIndex (td, th)

cellIndex property (td, th)

Browser support:
Returns a zero-based integer that indicates the position of a cell (td or th) in the cells collection of a table row.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Zero-based integer that retrieves the position of the td element.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the cellIndex property:
    <script type="text/javascript">
        function GetCellPos () {
            var cellPos = document.getElementById ("myCell").cellIndex;
            alert (cellPos);
    <table border="1px">
            <td>First cell in the table</td>
            <td id="myCell">Second cell id = myCell</td>
    <button onclick="GetCellPos ()">Get myCell's position!</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content