Remove table row using jQuery

前端 未结 6 1647
别跟我提以往
别跟我提以往 2021-02-19 03:57

The following is my code

Script

$(document).ready(function(){
    $(\'#click\').click(function(){
        $(\'#table\').append(\'&a         


        
6条回答
  •  灰色年华
    2021-02-19 04:54

    A demo is at http://jsfiddle.net/BfKSa/ or in case you are binding, add and delete to every row, this different demo http://jsfiddle.net/xuM4N/ come in handy.

    API: remove => http://api.jquery.com/remove/

    As you mentioned: This will delete the "delete the last row of the table"

    $('#table tr:last').remove(); will do the trick for your case.

    Code

    $(document).ready(function(){
        $('#click').click(function(){
            $('#table').append('foo add ');
        })
        $('#remove').click(function(){
            $('#table tr:last').remove();
        })
    })
    

提交回复
热议问题