How to add an onclick event on a newly added row (DataTables)?

人走茶凉 提交于 2019-12-31 05:40:36

问题


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?


回答1:


You can add an onclick to this event :

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


来源:https://stackoverflow.com/questions/51596062/how-to-add-an-onclick-event-on-a-newly-added-row-datatables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!