jQuery basic: How can i remove a table row when a button of this row is clicked?

Viewed 47542
$("#tableid tbody:last").append(html);

This creates table rows dynamically. Each newly created row has a "remove" button.

Now if i click that remove button that row will be deleted. How can i do this.

Thanks in advance.

4 Answers

You can remove the row by this below code HTML

<tr>
   <td class="text-center">4</td>
   <td>Abies Canadensis</td>
   <td>N/A</td><td>120</td>
   <td class="text-right">৳10</td>
   <td class="text-right">৳1200</td>
   <td><span class="close">×</span></td>
</tr>

JQuery

$("body").on("click", ".close", function () {
    $(this).parents('tr').remove();
 });
Related