I am trying to call a jQuery function upon clicking on the 4th 'td' as below. But it is not calling the function, I have tried different ways to get the row from the table.
<table class='logtable'>
<thead>
<tr>
<th>Time</th>
<th>Name</th>
<th>Log Note</th>
</tr>
</thead>
<tbody>
<?foreach ( $logRows as $logRow ){?>
<tr class="logtr">
<td><?=readable_date($logRow['date_created'])?></td>
<td><?=$logRow['first_name']></td>
<td><?=$logRow['log_note']?></td>
<td class="js-delete-log" data-log-id=<?=$logRow['log_id']?>><span class="delete"> <i class="fa fa-times"></i></span></td>
</tr>
<?}?>
</tbody>
</table>
Below is the JQuery function which is called from the 'td'.
// jQuery function to delete the log
$( "body" ).on( "click", ".js-delete-log", function(event) {
var el = $(this);
var log_id = el.data('log-id');
$.post( "../ajax/delete_logs.php", {log_id:log_id,action:'delete_log'} )
location.reload();
});
});
Can anyone please help on what's the issue here?
I tried the below method also.
// $("table.logtable tr.logtr td.js-delete-log").click(function() {