i m using jquery to add new row and delete them but my problem is that when i click on minus button it start deleting the row from bottom to up and not delete the particular row.means if i filled the data in 10 rows and now want to delete the 5th row then on cliking minus button on 5th row it removes 10th, 9th and so on…and i want that only 5th row will bdeletedhow could it will b possible.
Here is my jquery file:
$(document).ready(function(e) {
$("#add").click(function() {
$('#mytable tbody>tr:last').clone(true).insertAfter('#mytable tbody>tr:last');
var last_sn = $('#mytable tbody>tr:last>td:first').html();
$('#mytable tbody>tr:last>td:first').html(parseInt(last_sn) + 1);
return false;
});
$('#minus').click(function() {
$('#mytable tr:last-child').remove();
});
});
$(‘#mytable tr:last-child’).remove(); will allways remove the last row.
If you have several minus buttons then you should not use the same id (#minus) use a class instead.
fiddle: http://jsfiddle.net/k8dAs/