jQuery Clone table row

前端 未结 7 1125
悲&欢浪女
悲&欢浪女 2020-11-30 03:56

I have a table with an Add button on the end. When you click this button I want a new table row to be created underneath the current one. I also want the input fields on thi

相关标签:
7条回答
  • 2020-11-30 04:30

    The code below will clone last row and add after last row in table:

    var $tableBody = $('#tbl').find("tbody"),
    $trLast = $tableBody.find("tr:last"),
    $trNew = $trLast.clone();
    
    $trLast.after($trNew);
    

    Working example : http://jsfiddle.net/kQpfE/2/

    0 讨论(0)
提交回复
热议问题