cha*_*aya 3 jquery datatables jquery-datatables
我试图从datatable获取行号并传入一些更新函数.有时它将行号作为[Object object]这是我的代码:
var table = $('#example').DataTable();
$('#example tbody').on( 'click', 'tr', function ()
{
var idx = table.row( this ).index();
alert(idx);//Some times it alerts [Object object]
}
Run Code Online (Sandbox Code Playgroud)
小智 7
你可以用
$('#example tbody').on( 'click', 'td', function ()
{
var tr = $(this).closest("tr");
var rowindex = tr.index();
alert(rowindex);
});
Run Code Online (Sandbox Code Playgroud)
这样你就可以得到行的索引值.