简体   繁体   English

从行 id 和表 id 中获取行索引

[英]Get row index from row id and table id

I am trying to get Index no of a row when hyperlink is clicked i am passing some other data too from this tag我试图在点击超链接时获取一行的索引号 我也从这个标签传递了一些其他数据

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

I tried我试过

$('table#DoctorVisit tr#' + RowCount).index()
$('table#DoctorVisit tr#' + RowCount).closest.index()

But both are not working但两者都不起作用

This will give you the nearest row ID of a selected element.这将为您提供所选元素的最近行 ID。

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

In reply to your comment (again): http://jsfiddle.net/vcLvxycv/4/回复您的评论(再次): http : //jsfiddle.net/vcLvxycv/4/

This is independent of the row ID, will return the index as requested!这与行 ID 无关,将按要求返回索引!


OK!好的! Final edit I think I know what you mean.最后编辑我想我知道你的意思。 In the input box type one of the row IDs, it will then return that row's index在输入框中输入行 ID 之一,它将返回该行的索引

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM