Membuat table dengan javascript


function generateTable(table, data) {
no = 1;
for (let element of data) {
let row = table.insertRow();

// number
cell = row.insertCell();
text = document.createTextNode(no++);
cell.appendChild(text);

// name
cell = row.insertCell();
text = document.createTextNode(element['name']);
cell.appendChild(text);
}
}

let table = document.getElementById('tData');
let data = [
{id: 1, name: 'Lex'},
{id: 2, name: 'Clark'}
]

generateTable(table, data);
Share on Google Plus

About paslah.com

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment