用javascript,怎么获得表格中所点击的这一行的行数
我想获得所点击的某行,在表格中是排在第几行,应该要怎么得到?
我要实现的是:在某一行最后的一个单元格按回车,光标就跳到下一行的第一个单元格;
只要我获得了,当前的行是第几行,就可以知道下一行是处于表格的第几行(不知有没有其它的方法);
该怎么做,请大家帮帮忙,
------解决方案-------------------- <table width= "100% " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td> 0 </td>
</tr>
<tr id= "ro1 ">
<td> 1 </td>
</tr>
<tr>
<td> 2 </td>
</tr>
</table>
<script type= "text/javascript ">
var line = document.getElementById( "ro1 ");
var i = line.rowIndex, n = line.parentNode.rows[i + 1];
alert(line.innerHTML + "\n " + (n ? n.innerHTML : "尾行的说 "));
</script>
------解决方案--------------------首先取得出发事件的td对象(tdx)
tdx.parentNode.nextSibling.firstChild这个对象就是下一行的第一td对象.
------解决方案-------------------- <script language= "javascript ">
function showlinenum(obj){
var rownum = obj.rowIndex
document.all.dd.value=rownum;
}
</script>
<body>
<table width= "280 " border= "2 " cellspacing= "1 " cellpadding= "2 ">
<tr onMouseOver= "showlinenum(this) ">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver= "showlinenum(this) ">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver= "showlinenum(this) ">
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p>
<input name= "dd " type= "text " id= "dd " />
点击的话就换成onclick== "showlinenum(this) "
------解决方案-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>
<BODY>
<FORM METHOD=POST ACTION= " ">
<TABLE border=1 width=300 height=300>
<TR>
<TD> </TD>
<TD> </TD>
<TD> </TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD> </TD>
</ <TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD> </TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD> </TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD> </TD>