Jquery datatables在最后一列上单击“偶数”
我有这样的数据表代码Jquery datatables在最后一列上单击“偶数”,jquery,datatables,Jquery,Datatables,我有这样的数据表代码 var table = $("#mas-vendor"); var filter = $('.form-filter'); var target = table.attr('data-table'); var oTable = table.on( 'processing.dt', function ( e, settings, processing ) { if (processing) { $
var table = $("#mas-vendor");
var filter = $('.form-filter');
var target = table.attr('data-table');
var oTable = table.on( 'processing.dt', function ( e, settings, processing ) {
if (processing) {
$(this).find('tbody').addClass('load1 csspinner');
} else{
$(this).find('tbody').removeClass('load1 csspinner');
};
} ).DataTable({
"ajax": host+'datatable/'+target,
"bServerSide": true,
"iDisplayLength" : 10,
"order": [[ 1, "desc" ]],
"columnDefs": [{
"targets": [ 0 ],
"className": "details-control",
},]
});
html是这样的
<table id="mas-vendor" class="dataTable table table-bordered table-hover table-full-width" width="100%" data-table="masvendor">
<thead>
<tr>
<th>Name</th>
<th>Country</th>
<th>Terms</th>
<th>Cheque/Giro Name</th>
<th>PPN</th>
<th>NPWP</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
</table>
但我还是不知道如何在最后一篇专栏文章中使用它
更新:我的问题清楚!!!维琪思维的tq!!!) 试试这个
table.find('tbody').on('click', 'td:last-child a', function (){});
它将使最后一列的所有行都可单击。如果您知道它是第八列,则可以使用
table.find('tbody tr td').eq(7).on('click', 'a', function (){});
或者也可以使用.last()
如果您知道它是8列,那么您可以使用table.find('tbody tr td').eq(8).on('click','a',function(){});好吧,我试试看tq@AtalKishore:不工作,并且没有发生任何事情:(抱歉,将是
eq(7)
另请参见我的答案有工作示例您在数据中为按钮使用delete
和edit
的id。id应该是唯一的,因此我建议您将它们更改为名为delete
和edit
的类,然后您可以将@Vicky_的答案改编为:tatable.find('tbody')。在('click','a.delete',function(){})上;
。。。
table.find('tbody').on('click', 'td:last-child a', function (){});
table.find('tbody tr td').eq(7).on('click', 'a', function (){});
table.find('tbody tr td').last().on('click', 'a', function (){});