Skip to content

Instantly share code, notes, and snippets.

@totoprayogo1916
Created February 1, 2022 04:46
Show Gist options
  • Save totoprayogo1916/f3c8e5d86ef0d5266e8be7be7962fe6e to your computer and use it in GitHub Desktop.
Save totoprayogo1916/f3c8e5d86ef0d5266e8be7be7962fe6e to your computer and use it in GitHub Desktop.
create table (vanilla JS)
var placeTable = document.getElementById('tableDetail')
// clean placeTable
placeTable.innerHTML = ''
// (C1) CREATE EMPTY TABLE
var table = document.createElement("table"),
row, cellA, cellB;
table.classList.add('table', 'table-bordered')
placeTable.appendChild(table);
for (let key in data) {
// (C2) ROWS & CELLS
row = table.insertRow();
cellA = row.insertCell();
cellB = row.insertCell();
// (C3) KEY & VALUE
cellA.innerHTML = key;
cellB.innerHTML = data[key];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment