如何在新添加的行(DataTables)上添加onclick事件? [英] How to add an onclick event on a newly added row (DataTables)?

查看:377
本文介绍了如何在新添加的行(DataTables)上添加onclick事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

动态添加行

  table.row.add 

我希望,对于添加到表中的每一行,还要向该行添加onclick事件,以便链接到URL。 / p>

那么,我如何引用刚刚添加的行来添加此事件?

解决方案

您可以在此活动中添加 onclick

  $(document).ready(function(){
$('#example')。DataTable({
createdRow:function(row,data,index)
{
//这里
}
});
});


I'm adding rows dynamically using

table.row.add

and I want to, for every row that is added to the table, to also add an onclick event to that row so it links to a URL.

So, how do I refer to the row that has just been added to add this event?

解决方案

You can add an onclick to this event :

 $(document).ready(function() {
 $('#example').DataTable( {
      "createdRow": function ( row, data, index )
       {
           // here
       }
    } );
 } );

这篇关于如何在新添加的行(DataTables)上添加onclick事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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