解决方案 »

  1.   


    <table width="500px">
    <thead>
    <tr>
    <td>1</td>
    <td>2</td>
    </tr>
    <tr>
    <td><input type="button"  onclick="addRow()" value="create"  /></td>
    <td><input type="button"  onclick="removeRow()" value="remove"  /></td>
    </tr>
    </thead>

    <tbody>

    </tbody>
    <tfoot>
    <tr>
    <td><input type="button"  onclick="addRow()" value="create"  /></td>
    <td><input type="button"  onclick="removeRow_2()" value="remove"  /></td>
    </tr>
    </tfoot>
    </table>
    function addRow(){
    $('table tbody').append(
     $('<tr>').append(
    $('<td>').text($('table tbody tr').length),
    $('<td>').html(
    $('<input>').attr("type","button")
    .attr("value","remove this")
    .click(function() {
    $(this).parents("tr:first").remove();
    })
    )
     )
    );
    }
    function removeRow(){
    $('table tbody tr:last').remove();
    }
    你试试吧~
      

  2.   

    DEMO>>>>>>>>>>>>>http://jsfiddle.net/DKWnE/1/
      

  3.   

    //html  表格
    <table id='datatable'></table>建立一个数组 包含表格数据 一个元素 相当于包含一行tr
    var datas = [];一个方法添加数据(注意 添加数据只要修改 datas就可以了)
    function adddata(index){   //在第数组的第几行处添加数据
         //代码自己写
        //最后
        renderer(datas);  //重新刷新显示
    }
    一个方法删除数据(同上  只处理 datas)
    function deldata(index){   //删除数组指定索引的行
         //代码自己写
         //最后
        renderer(datas);  //重新刷新显示
    }   一个方法 吧数组渲染成表格
    function renderer(datas){
        //这个还是自己写 就是dom插入操作么
       for(var i=0;i<datas.length;i++){
             var index = i;'
              //每行的按钮只要绑定 上面  adddata  , deldata方法就可以了
      }
    }
    //任何mvc东西 这样一拆分 应该很简单