Create Clone Of Table Row And Append To Table In JavaScript
Answer : If you don't wish to use jQuery, there are a couple of simple functions you could use, like cloneNode() , createElement() and appendChild() . Here is a simple demonstration that appends a row to the end of the table using either the clone or create method. Tested in IE8 and FF3.5. <html> <head> <script type="text/javascript"> function cloneRow() { var row = document.getElementById("rowToClone"); // find row to copy var table = document.getElementById("tableToModify"); // find table to append to var clone = row.cloneNode(true); // copy children too clone.id = "newID"; // change id or other attributes/contents table.appendChild(clone); // add new row to end of table } function createRow() { var row = document.createElement('tr'); // create row node var col = document.createElement('td'); // create column node var col2 = document.createEl