table.insertRow(integer);
var tableElement = document.getElementById('myTable'); var countOfCell = 5; //for example table.onclick = function ( eventObj ) { var target = eventObj && eventObj.target || window.event.srcElement; while ( target.nodeName.toLowerCase() != 'tr' ) {//get table row target = target.parentNode; } var nextTableRow = target.nextSibling; while ( nextTableRow && nextTableRow.nodeType != 1 ) { nextTableRow = nextTableRow.nextSibling; } if ( !nextTableRow ) return;//last row var currenIndexRow = 0, tableRow = target.previousSibling; while ( tableRow ) { if ( tableRow.nodeType == 1 ) { currenIndexRow++; } tableRow = tableRow.previousSibling; } var newRow = tableElement.insertRow( currenIndexRow + 1 ); for ( var i = 0, newCell; i < countOfCell; i++ ) {//create new cell newCell = newRow.inserCell(i); newCell.appendChild ( document.createTextNode( "Cell" + i ) ); } }