数据表列onClick [英] Datatable column onClick

查看:47
本文介绍了数据表列onClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指的是以下数据表示例-

I am referring the following Datatable example -

https://datatables.net/examples/api/select_single_row.html

该示例捕获整行的onclick事件

https://datatables.net/examples/api/select_single_row.html
The example captures onclick event on the entire row

$('#example tbody').on( 'click', 'tr', function (){}

我希望通过单击特定列来捕获事件,
说出名称,位置和办公室列。 $ b我该怎么做?

I wish to capture an event on the click of a particular columns, say column Name, Position and Office. How do I do that?

推荐答案

如果您知道表列索引,则可以使用它。

If you know the table colums index then you might you use this.

$('#example tbody').on( 'click', 'tr td:eq(0)', function (){
   alert("col1");
});
$('#example tbody').on( 'click', 'tr td:eq(1)', function (){
   alert("col2");
});
$('#example tbody').on( 'click', 'tr td:eq(4)', function (){
   alert("col5");
});

这篇关于数据表列onClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆