2015-06-22 25 views
2

我試圖讓指數不連續的點擊時超鏈接是我傳遞一些其他的數據也從該標籤獲得由行ID和表ID行索引

<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() 

但是兩者都不起作用

+0

添加完整的代碼 – Tushar

+0

完整代碼意味着我是如何創建動態表和所有?我只是想使用行號獲取索引號 – Kirtesh

+0

你想在哪裏獲得'索引'? – Tushar

回答

1

這會給你一個選定元素的最近行ID。

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

在回答您的評論(再次):http://jsfiddle.net/vcLvxycv/4/

這是獨立於行ID,將返回指標的要求!


行!最終編輯我想我知道你的意思。在輸入框中鍵入該行ID之一,它就會返回該行的索引

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