js代码:增加一行五列的表格
function AddList(){ obj = document.getElementById(‘tab_g‘); $str1 = ‘1‘; $str2 = ‘2‘; $str3 = ‘3‘; $str4 = ‘4‘; $str5 = ‘5‘; newTr = document.createElement(‘tr‘); newTd1 = document.createElement(‘td‘); newTd2 = document.createElement(‘td‘); newTd3 = document.createElement(‘td‘); newTd4 = document.createElement(‘td‘); newTd5 = document.createElement(‘td‘); newTd1.innerHTML = $str1; newTd2.innerHTML = $str2; newTd3.innerHTML = $str3; newTd4.innerHTML = $str4; newTd5.innerHTML = $str5; newTr.appendChild(newTd1); newTr.appendChild(newTd2); newTr.appendChild(newTd3); newTr.appendChild(newTd4); newTr.appendChild(newTd5); document.getElementById(‘tab_g‘).appendChild(newTr) }
时间: 2024-10-12 21:23:50