JSFiddle - React, Tailwind, and code Playground
HTML
<h2>Books</h2>
<table id="dataTable">
<thead></thead>
<tbody></tbody>
</table>
JavaScript
JSONCollection = {
"genres": [{
"genre": "Horror",
"publishers": [{
"publisherName": "Random House",
"authors": [{
"authorName": "John Smith",
"bookDetails": [{
"Blurb": "Provided",
"Review": 3,
"Type": "Fiction"
}]
}]
}]
}, {
"genre": "Romance",
"publishers": [{
"publisherName": "Penguin",
"authors": [{
"authorName": "William Shakespeare",
"bookDetails": [{
"Blurb": "Not Provided",
"Review": 5,
"Type": "Fiction"
}]
}]
}]
}]
}
var table = $('#dataTable')
var table_thead = table.find('thead')
table_thead.empty()
var tr_head = $('<tr>')
.append($('<th>').text('publishers'))
.appendTo(table_thead)
var table_tbody = table.find('tbody')
table_tbody.empty();
var tr_body = $('<tr>');
$.each(JSONCollection.genres, function (i, item) {
$.each(item.publishers, function (i, item) {
tr_body.append($('<td...