Created
February 1, 2022 04:46
-
-
Save totoprayogo1916/f3c8e5d86ef0d5266e8be7be7962fe6e to your computer and use it in GitHub Desktop.
create table (vanilla JS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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