用户名: 密码: 企业 个人
当前位置:89学习网范文文章生活常识电脑常识js获得当前的行是表格的第几行代码» 正文

js获得当前的行是表格的第几行代码

[05-26 12:48:56]   来源:http://www.89xue.com  电脑常识   阅读:90
摘要:<script>function getrow(obj){if(event.srcElement.tagName=="TD"){curRow=event.srcElement.parentElement;alert("这是第"+(curRow.rowIndex+1)+"行");}}</script><table border="1" width="100%" onclick=getrow(this)><tr><td width="20%"&g。
js获得当前的行是表格的第几行代码,标签:电脑常识范文,http://www.89xue.com

<script>

function getrow(obj)

{

if(event.srcElement.tagName=="TD"){

curRow=event.srcElement.parentElement;

alert("这是第"+(curRow.rowIndex+1)+"行");

}

}

</script>

<table border="1" width="100%" onclick=getrow(this)>

<tr>

<td width="20%"> </td>

<td width="20%"> </td>

<td width="20%"> </td>

<td width="20%"> </td>

<td width="20%"> </td>

</tr>

<tr>

<td width="20%"> </td>

<td width="20%"> </td>

<td width="20%"> </td>

<td width="20%"> </td>

<td width="20%"> </td>

</tr>

</table>//


Tag:电脑常识电脑常识范文生活常识 - 电脑常识