Copy a table row from one table to another using jQuery

后端 未结 1 1992
自闭症患者
自闭症患者 2021-01-21 11:55

I need to be able to copy a row from one table to the other using jQuery when a checkbox in that row is checked.

I tried using the .clone() method but this

相关标签:
1条回答
  • 2021-01-21 12:26
    $('#offers tbody tr td input.checkbox:not(:checked)').on('change', function (e) {
         var row = $(this).closest('tr').html();
         $('#otherTable tbody').append('<tr>'+row+'</tr>');
    });
    

    See it in action! http://jsfiddle.net/3BZp4/1/

    Clone also SHOULD work for you and not effect future selection:

    http://jsfiddle.net/AkVTw/1/

    Now with catch for unchecking as per comments:

    http://jsfiddle.net/wGGDb/

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