const q3Msg = document.getElementById('tableq3');
var value = [{
id: 1,
result: 65,
situation: 'YES'
}, {
id: 2,
result: 22,
situation: 'NO'
}];
function q3Calc() {
q3Msg.classList.remove('hidden');
var table = document.createElement('tbody'), tr, td, row, cell;
for (row = 0; row < value.length; row++) {
console.log(value);
tr = document.createElement('tr');
for (cell = 0; cell < 3; cell++) {
td = document.createElement('td');
tr.appendChild(td);
td.innerHTML = value;
}
table.appendChild(tr);
}
document.getElementById('tableq3').appendChild(table);
}
我有上述代碼在html中自動執行tds
。但我有下面的圖像。使用Javascript的Tds自動化
我如何可以顯示在一個單獨的TD每個數組索引?
例如,在第一行中,我想顯示1個65 YES,和下一行2 22 NO
謝謝您的回答!問題解決了! –
不客氣! – Duannx