动态新增删除表格行(复制整行)

var rowIndex = 0;
function addLine(obj) {
		var objSourceRow = obj.parentNode.parentNode;
		var objTable = obj.parentNode.parentNode.parentNode.parentNode;
		if (obj.value == '增加') {
			rowIndex++;
			var objRow = objTable.insertRow(rowIndex);
			var objCell;
	
			objCell = objRow.insertCell(0);
			objCell.innerHTML = objSourceRow.cells[0].innerHTML;
			objCell = objRow.insertCell(1);
			objCell.innerHTML = objSourceRow.cells[1].innerHTML;
	
			objCell = objRow.insertCell(2);
			objCell.innerHTML = objSourceRow.cells[2].innerHTML.replace(/增加/, '删除');
		} else {
			objTable.lastChild.removeChild(objSourceRow);
			rowIndex--;
		}
	}

你可能感兴趣的:(删除)