//动态添加行 function addRow(){ var table = document.getElementById("tableID"); var newRow = table.insertRow(); //创建新行 var newCell1 = newRow.insertCell(); //创建新单元格 newCell.innerHTML = ""; //单元格内的内容 newCell.setAttribute("align","center"); //设置位置 }
//动态删除行 function deleteRow(){ var rowIndex = event.srcElement.parentElement.parentElement.rowIndex; var styles = document.getElementById("tableID"); styles.deleteRow(rowIndex); }