Reputation: 117
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
Upvotes: 3
Views: 3191
Reputation: 1394
This will give you the nearest row ID of a selected element.
var row_id = $(this).closest('tr').index()
In reply to your comment (again): http://jsfiddle.net/vcLvxycv/4/
This is independent of the row ID, will return the index as requested!
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
http://jsfiddle.net/vcLvxycv/7/
Upvotes: 1