数据表在特定列上启用onclick [英] Datatable Enable onclick on a specific column

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

问题描述

我有一个数据表,我希望第二列是唯一可单击的列.这是设计的图片.

I have a datatable and I want the 2nd column to be the only clickable column. Here is a picture of the design.

我希望引用ID"列(第2列)可以用Javascript形式单击.单击后,将仅从列中获取数据.

I intended the Reference ID column (2ndcolumn) to be the one to be clickable in Javascript form please. When clicked it will get the data from the column just that.

我的桌子只是通常的<表格><tr><td></td></tr></表> .我也希望它是动态的,因此当我必须从数据库中插入一个数组时,单击第二列仍将起作用.

My table is just the usual < table > < tr> < td> < /td >< /tr >< / table >. I also want it to be dynamic so when I have to insert an array from my database the click for the 2nd column will still work.

推荐答案

您可以尝试一下.

$('#exampleTable tbody tr').on('click', 'td:eq(1)', function () {
 /* Your function code here */
} );

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

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