jquery - How do I delete a table row? -
i tried make following code work last 5-6 hours, had no luck.
can please me understand what's wrong code? after clicking on delete link nothing happens.
here table:
<table id="links"> <tr id="record-<?php echo $row['feepaymentid']; ?>"> <td><?php echo $row['masterentryvalue']; ?></td> <td><?php echo $row['amount']; ?></td> <td><a href="#" class="delete">delete</a></td> </tr> </table>
here javascript:
$('table#links td a.delete').click(function() { if (confirm("are sure want delete row?")) { var id = $(this).parent().parent().attr('id'); var data = 'id=' + id ; var parent = $(this).parent().parent(); $.ajax({ type: "post", url: "deleterow.php", data: data, cache: false, success: function() { parent.fadeout('slow', function() {$(this).remove();}); } }); } })
the selector isn't correct, try this: $('#links a.delete')
select anchor elements class 'delete' under element id 'links'
Comments
Post a Comment