admin管理员组

文章数量:1356536

I have a table which is dynamically created , there is a checkbox in each row of the table, when user click that checkbox the whole row of the dynamically created table needs to deleted.

I have a table which is dynamically created , there is a checkbox in each row of the table, when user click that checkbox the whole row of the dynamically created table needs to deleted.

Share Improve this question edited Jan 4, 2011 at 22:27 Pinu asked Jan 4, 2011 at 19:55 PinuPinu 7,53016 gold badges55 silver badges77 bronze badges 1
  • 1 Can give a more accurate answer if you include a snippet of the HTML for the table/checkbox. – JohnFx Commented Jan 4, 2011 at 19:56
Add a ment  | 

5 Answers 5

Reset to default 7
$("tr input:checkbox").live("click", function(){ 
    $(this).closest("tr").remove(); 
});
$(function(){
    $(".yourCheckboxClass").change(event){
        function(){
            $(this).closest('tr').remove();
        }
    }
});
$('table').delegate('tr input:checkbox', 'click', function () {
    $(this).closest('tr').remove();
});

Demo here

You can apply this specific table, like this.

$("#yourtableID  tr").live("click", function(){ 
    $(this).closest("tr").remove(); 
});
$('table.grid input:checkbox').change(function(){
    $(this).parents('tr').remove();
});

本文标签: javascriptjquery delete table row on click on check boxStack Overflow