javascript - remove a row from dynamically created table using jquery -
in form im creating dynamic table of template below.
<table id="newservice" style="display:none"> <tr> <td><input id="type-%" style="width:100px" class="act_type" type="text" name="provider_service_dtls[#].activity_type" readonly value /></td> <td><input id="code-%" class="act_code" style="width:150px" type="text" name="provider_service_dtls[#].activity_code" value /></td> <td><input id="start-%" class="datepicker" style="width:125px" type="text" name="provider_service_dtls[#].activity_start_date" value /></td> <td><input id="clinician-%" class="clini" style="width:200px" type="text" name="provider_service_dtls[#].clinician" value /></td> <td><input id="net-%" class="" style="width:40px" type="text" name="provider_service_dtls[#].net_amt" value /></td> <td><input id="qty-%" class="" style="width:40px" type="text" name="provider_service_dtls[#].quantity" value /> <input type="hidden" name="provider_service_dtls.index" value="%" /> </td> <td><input id="delete" class="delete" value="x" type="button"></td> </tr> </table>
when clicking new button creating new row table "service" successfully.
now when clicking "x" button in row need delete same.
i wrote jquery below
$('#service').on('click', buttonselector, function () { $(this).closest('tr').remove(); });
but not working..anybody done before. please help
try update :
$('#service').on('click', 'td input.delete', function () { $(this).closest('tr').remove(); });
Comments
Post a Comment