A friend in IECN asked how to get the row and column numbers of a cell in a table, which can be obtained with rowindex and CellIndex.
See the following code for a specific effect
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < HTML xmlns= "http://www.w3.org/1999/xhtml" lang= "gb2312" > <pead> <title> Get Table rowindex and CellIndex & lt;/title> <meta http-equiv= "Content-type" content= "text/html"; charset=gb2312 "/> <meta name=" generator "content=" EditPlus "/> <meta name=" author "content=" Maple Rock, cnlei.y.l@ gmail.com "/> <meta name=" keywords "content=" rowindex,cellindex "/> <script type=" Text/javascript "> O nload = function () {if (!document.getelementsbytagname | |!document.createtextnode) return; var rows = document.getElementById (' MyTable '). getElementsByTagName (' tbody ') [0].getelementsbytagname (' tr '); var cols; for (i = 0; i < rows.length i++) {Rows[i].onclick = function () {alert ("line:" +eval (This.rowindex + 1)); } cols = Rows[i].getelementsbytagname (' TD '); for (j = 0; J < Cols.length; J + +) {Cols[j].onclick = function () {Alert (column: "+eval (This.cellindex + 1)); </script> </pead> <body> <table id= "MyTable" border= "1" > <tbody> ; <tr><td> row 1 column 1</td><td> row 1 column 2</td><td> row 1 column 3</td></tr> <tr>< Td> row 2 column 1</td><td> row 2 column 2</td><td> row 2 column 3</td></tr> <tr><td> row 3 column 1< /td><td> row 3 column 2</td><td> row 3 column 3</td></tr> </tbody> </table> </body> & Lt;/html>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]