DOM methods | function tableDOM() {
var i, table, thead, tbody, tr, th, td, a, ul, li;
tbody = document.createElement('tbody');
for (i = 1; i <= 1000; i++) {
tr = document.createElement('tr');
td = document.createElement('td');
td.appendChild(document.createTextNode((i % 2) ? 'yes' : 'no'));
tr.appendChild(td);
td = document.createElement('td');
td.appendChild(document.createTextNode(i));
tr.appendChild(td);
td = document.createElement('td');
td.appendChild(document.createTextNode('my name is #' + i));
tr.appendChild(td);
a = document.createElement('a');
a.setAttribute('href', 'http://example.org/' + i + '.html');
a.appendChild(document.createTextNode('http://example.org/' + i +
'.html'));
td = document.createElement('td');
td.appendChild(a);
tr.appendChild(td);
ul = document.createElement('ul');
a = document.createElement('a');
a.setAttribute('href', 'edit.php?id=' + i);
a.appendChild(document.createTextNode('edit'));
li = document.createElement('li');
li.appendChild(a);
ul.appendChild(li);
a = document.createElement('a');
a.setAttribute('href', 'delete.php?id=' + i);
a.appendChild(document.createTextNode('delete'));
li = document.createElement('li');
li.appendChild(a);
ul.appendChild(li);
td = document.createElement('td');
td.appendChild(ul);
tr.appendChild(td);
tbody.appendChild(tr);
}
tr = document.createElement('tr');
th = document.createElement('th');
th.appendChild(document.createTextNode('yes?'));
tr.appendChild(th);
th = document.createElement('th');
th.appendChild(document.createTextNode('id'));
tr.appendChild(th);
th = document.createElement('th');
th.appendChild(document.createTextNode('name'));
tr.appendChild(th);
th = document.createElement('th');
th.appendChild(document.createTextNode('url'));
tr.appendChild(th);
th = document.createElement('th');
th.appendChild(document.createTextNode('action'));
tr.appendChild(th);
thead = document.createElement('thead');
thead.appendChild(tr);
table = document.createElement('table');
table.setAttribute('border', 1);
table.setAttribute('width', '100%');
table.appendChild(thead);
table.appendChild(tbody);
document.getElementById('here').appendChild(table);
};
tableDOM();
| ready |