最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery delete table row on click on check box - Stack Overflow

programmeradmin1浏览0评论

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();
});
发布评论

评论列表(0)

  1. 暂无评论