<html>
<body>
<script type="text/javascript">
function clicke(x){
//获取当前所在行数
alert(x.parentNode.parentNode.rowIndex);
//需要引入jquery才能获取当前行对应的值
// var id=$(x).parent().find(".first").val();
//alert(id)
}
</script>
<table>
<tr>
<td>
<input class="first" type="button"value="1"οnclick="clicke(this)"/>
<input class="seconde" type="button"value="2"οnclick="clicke(this)"/>
<input class="third" type="button"value="3"οnclick="clicke(this)"/>
</td>
</tr>
<tr>
<td>
<input class="first" type="button"value="1"οnclick="clicke(this)"/>
<input class="seconde" type="button"value="2"οnclick="clicke(this)"/>
<input class="third" type="button"value="3"οnclick="clicke(this)"/>
</td>
</tr>
<tr>
<td>
<input class="first" type="button"value="1"οnclick="clicke(this)"/>
<input class="seconde" type="button"value="2"οnclick="clicke(this)"/>
<input class="third" type="button"value="3"οnclick="clicke(this)"/>
</td>
</tr>
</table>
</body>
</html>
获取table当前所在行
最新推荐文章于 2023-09-07 18:01:06 发布