HTML DOM TableHeader cellIndex Property
the TableHeader cellIndex Property in HTML DOM is used for returning the position of a cell in the cells collection of a table row.
Syntax:
- It returns the cellIndex Property:
tableheaderObject.cellIndex
Return Value: It returns a numeric value that represents the position of the cell in the cells collection of a table row.
Example:
HTML
<!DOCTYPE html> < html > < head > <!-- style to set border --> < style > table, th, td { border: 1px solid black; } </ style > </ head > < body > < h1 >w3wiki</ h1 > < h2 >DOM TableHeader CellIndex Property</ h2 > < table > < tr > < th id = "gfg" onclick = "myBeginner(this)" > Username </ th > < th id = "gfg" onclick = "myBeginner(this)" > Id </ th > </ tr > < tr > < td >Beginner</ td > < td >23456</ td > </ tr > </ table > < p > Click on TableHeader to get the CellIndex th element. </ p > <!-- Script to return cellIndex Property --> < script > function myBeginner(x) { alert("cell index is: " + x.cellIndex); } </ script > </ body > </ html > |
Output:
Supported Browsers: The browsers supported by DOM TableHeader cellIndex Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera