var theRow = event.srcElement;
while (theRow.tagName != "TR")
{
theRow = theRow.parentElement;
}
for (var i=0; i<oTable.rows.length; i++)
{
if (theRow == oTable.rows[i])
alert(i)
}
while (theRow.tagName != "TR")
{
theRow = theRow.parentElement;
}
for (var i=0; i<oTable.rows.length; i++)
{
if (theRow == oTable.rows[i])
alert(i)
}
function kao() {
a.innerText = "第"+(event.srcElement.tagName=="TD" ? event.srcElement.parentElement.rowIndex+1 : "")+"行";
}
</script><TABLE id=tbl cellSpacing=1 cellPadding=1 border=1 onmouseover=kao()>
<TBODY>
<TR>
<TD width=100>This is Line1</TD></TR>
<TR>
<TD width=100>This is Line2</TD></TR>
<TR>
<TD width=100>This is Line3</TD></TR>
</TBODY>
</TABLE><span id="a"></span>