Good day, I am looking to create an HTML table that reads data from a separate table using JQuery. I found a code snippet online but after including that into my project no new data displayed in my table. Please could you help me figure out what the problem is ? Below is the JS code snippet I am incorporating and the code for my two data tables.
JS Code Snippet:
$("#table1").find("thead").each(function(){
$table1Head=$(this).find("th");
$("#table3 thead").append(". <th>"+$table1Head.eq(1).text()+ " </th>");
$("#table3 thead").append("<th>"+$table1Head.eq(1).text()+ " </th>");
$("#table3 thead").append("<th>"+$table1Head.eq(1).text()+ " </th>");
$("#table3 thead").append("<th>"+$table1Head.eq(1).text()+ " </th>");
});
$("#table1 tbody").find("tr").each(function(){
$table3data=$(this).find("td");
$("#table3 tbody").append("<tr>"+
"<td>" + $table3data.eq(1).text() + "</td>" +
"<td>" + $table3data.eq(2).text() + "</td>" +
"<td>" + $table3data.eq(4).text() + "</td>" +
"<td>" + $table3data.eq(5).text() + "</td>" +
"</tr>");
});///
I have tried to incorporate the JS script and then tried to manipulate the table I would like to display the data in by placing the class and id’s within the element of the HTML table. No data displays in any of the cells though.
Andrew Chibwesha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.