1Window.onload =function(){2 varTable = document.createelement (' table ');3Table.border = 1;4Table.width = ' 100% ';5 vartbody = document.createelement (' tbody '));6 Table.appendchild (tbody);7 //the protagonist came into the InsertRow; the function is to insert a row into the specified position rows returns all rows of the table cells returns all cells insertcell the same as InsertRow except that it is inserting a cell into the specified position. 8 9Tbody.insertrow (0);//Create a rowTenTbody.rows[0].insertcell (0);//Create first Row first cell OneTbody.rows[0].cells[0].appendchild (document.createTextNode (' n '));//add text to a cell ATbody.rows[0].insertcell (1);//Create the second cell of the first row -Tbody.rows[0].cells[1].appendchild (' document.createTextNode ')); -Tbody.insertrow (1); theTbody.rows[1].insertcell (0);//Create the first cell of the second row -Tbody.rows[1].cells[0].appendchild (document.createTextNode (' 2,1 '))); -Tbody.rows[1].insertcell (1);//Create second cell of second row -Tbody.rows[1].cells[1].appendchild (document.createTextNode (' 2,2 '))); +Tbody.rows[1].insertcell (2); -Tbody.rows[1].cells[2].appendchild (document.createTextNode (' 2,3 '))); + document.body.appendChild (table); A}
Please correct me in the wrong place.
JS Dynamic CREATE Table method