Add/delete row from a table

前端 未结 7 1622
盖世英雄少女心
盖世英雄少女心 2020-12-01 04:51

I have this table with some dependents information and there is a add and delete button for each row to add/delete additional dependents. When I click \"add\" button, a new

7条回答
  •  不知归路
    2020-12-01 05:19

    Hi I would do something like this:

    var id = 4; // inital number of rows plus one
    function addRow(){
       // add a new tr with id 
       // increment id;
    }
    
    function deleteRow(id){
       $("#" + id).remove();
    }
    

    and i would have a table like this:

    Relationship Type Date of Birth Gender
    Spouse 1980-22-03 female
    Child 2008-23-06 female

    Also if you want you can make a loop to build up the table. So it will be easy to build the table. The same you can do with edit:)

提交回复
热议问题