简体   繁体   中英

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

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
       }
    } );
 } );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM