javascript中如何获取表格中的当前行号

feng_43 2008-03-04 05:35:24
javascript中如何获取表格中的当前行号?谢谢了啊!!!!
...全文
3987 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
azenis_xing 2011-12-17
  • 打赏
  • 举报
回复
ls真是好人呐~
feng_43 2008-03-04
  • 打赏
  • 举报
回复
运行出来了。谢谢大家啊!小弟在这祝大家天天幸福开心啊!
cnchart 2008-03-04
  • 打赏
  • 举报
回复
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
</tr>
<tr>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
</tr>
<tr>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
</tr>
<tr>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
</tr>
<tr>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
<td onclick="alert(this.cellIndex)"> </td>
</tr>
</table>
feng_43 2008-03-04
  • 打赏
  • 举报
回复
我测试时为什么出现“undefinde”啊?
cnchart 2008-03-04
  • 打赏
  • 举报
回复
测试了一下,是cellIndex
cnchart 2008-03-04
  • 打赏
  • 举报
回复
测试了一下,是cellIndex
cnchart 2008-03-04
  • 打赏
  • 举报
回复
既然行是this.rowIndex,我估计列号是this.colIndex
feng_43 2008-03-04
  • 打赏
  • 举报
回复
我已经运行成功了。
谢谢啊!还想问一下能不能获得列号 啊?谢谢啊
cnchart 2008-03-04
  • 打赏
  • 举报
回复
呵呵,跟着2楼学了一招
cnchart 2008-03-04
  • 打赏
  • 举报
回复
<script language="javascript">
function fx(v){
var target=document.getElementsByTagName("tr")
for(var i=0;i<target.length;i++)
if(v==target[i])
alert("行号:"+parseInt(i+1))
}
</script>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr onclick="fx(this)">
<td> </td>
</tr>
<tr onclick="fx(this)">
<td> </td>
</tr>
<tr onclick="fx(this)">
<td> </td>
</tr>
<tr onclick="fx(this)">
<td> </td>
</tr>
<tr onclick="fx(this)">
<td> </td>
</tr>
</table>
myvicy 2008-03-04
  • 打赏
  • 举报
回复
<table width="100%" border="1">
<tr onclick=alert(this.rowIndex)>
<td> </td>
</tr>
<tr onclick=alert(this.rowIndex)>
<td> </td>
</tr>
<tr onclick=alert(this.rowIndex)>
<td> </td>
</tr>
<tr onclick=alert(this.rowIndex)>
<td> </td>
</tr>
<tr onclick=alert(this.rowIndex)>
<td> </td>
</tr>
</table>
zzuchengxu 2008-03-04
  • 打赏
  • 举报
回复
呵呵,没听说过这样取的。你实现什么功能?可以换一下思路实现

87,924

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧