单击超链接时,我试图获取行的索引号,我也从该标签传递其他数据

<a href="javascript:void(0);" onclick="EditDoctorRow(' + RowCountDoctorVisit + ');">
    <i class="fa fa-edit"></i>
</a>

我试过了
$('table#DoctorVisit tr#' + RowCount).index()
$('table#DoctorVisit tr#' + RowCount).closest.index()

但是两者都不起作用

最佳答案

这将为您提供所选元素的最接近的行ID。

var row_id = $(this).closest('tr').index()

再次回复您的评论:http://jsfiddle.net/vcLvxycv/4/

这与行ID无关,将按要求返回索引!

好!最后的编辑,我想我知道你的意思。在输入框中,输入行ID之一,然后它将返回该行的索引

http://jsfiddle.net/vcLvxycv/7/

关于javascript - 从行ID和表ID获取行索引,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30979044/

10-10 22:12