-1

I am trying to move data from a table to another table but not working. How to append data? https://jsfiddle.net/ue1j6405/

    $(".copy-data").click(function(){ 

        $("table tbody tr").each(function(){ 
        var cnts=$(this).find('td:eq(0)').val();
        var name=$(this).find('td:eq(0)').val();
        var email=$(this).find('td:eq(0)').val(); 
           $("#tablesTwo").append('<tr><td>"+ cnts +"</td><td>" + name + "</td><td>" + email + "</td></tr>') 

        });
    });
RojaS
  • 29
  • 1
  • 8
  • The duplicate uses the DOM directly, but it's the same issue with jQuery. Use `text` or `html`, not `val`, with `td` elements. – T.J. Crowder Jan 29 '19 at 13:10

1 Answers1

0

Can you try like below:

$(".copy-data").click(function(){ 
            $("table tbody tr").each(function(){
                var cnts=$(this).find('td:eq(0)').text();
                var name=$(this).find('td:eq(1)').text();
                var email=$(this).find('td:eq(2)').text();
                $("#tablesTwo").append("<tr><td>"+ cnts +"</td><td>" + name + "
                                      </td><td>" + email + "</td></tr>")
            });
});
sri harsha
  • 676
  • 6
  • 16