Hello I am facing a problem that is so small but cant make it.I have a master table from where I took some header and column data and bind those data in another dynamic created table .Its working fine .But the problem is when I remove the dynamic generated table and try again to re-create it as I did before it is not working.
My jquery code is like below
$('input[type="submit"]').click(function(){
$("#table1").find("thead").each(function(){
$table1Head=$(this).find("th");
$("#table2 thead").append("<th>"+$table1Head.eq(1).text()+ " </th>");
$("#table2 thead").append("<th>"+$table1Head.eq(3).text()+ " </th>");
});
$("#table1 tbody").find("tr").each(function(){
$table2data=$(this).find("td");
$("#table2 tbody").append("<tr> <td><input type='text'
name='first_name[]' value="+$table2data.eq(1).text()+"></td> <td><input
type='text' name='last_name[]' value="+$table2data.eq(3).text()+">
</td></tr>");
});
});
$(document).on("click","#clear",function(){
$("#table2").empty();
});
A working fiddle with full code is added below