< html >
< head >
</ head >
< body >
< button onclick ="add_row()" > Add </ button >
< button onclick ="alert(document.getElementById('place').innerHTML)" > Show inner </ button >
< div id ="place" ></ div >
< script type ="text/javascript" >
var place = document .getElementById( "place" );
var table = document .createElement( "table" );
place.appendChild(table);
function add_row() {
var row = document .createElement( "tr" );
var c1 = document .createElement( "td" );
var c2 = document .createElement( "td" );
row.appendChild(c1);
row.appendChild(c2);
table.appendChild(row);
c1.innerHTML = "cell1" ;
c2.innerHTML = "cell2" ;
}
</ script >
</ body >
</ html >
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/55850/
All Articles