function getInnerHTML() {
// alert(document.getElementById("tr1").innerHTML);
var input = document.createElement("input");
input.type = "text";
input.id = "txte1";
document.body.insertBefore(input, t1);
init();
}
function init() {
var table = document.createElement("table");
var tbody = document.createElement("tbody");
for (var i = 1; i < 10; i++) {
var row = document.createElement("tr");
row.id = i;
if (i!=4 && i%2) {
row.bgColor = "#ffff00";
} else if (i == 4) {
row.bgColor = "#ff0000";
} else {
row.bgColor = "#0000ff";
}
for (var j = 1; j < 6; j++) {
var cell = document.createElement("td");
cell.id = i + "/" + j;
cell.appendChild(document.createTextNode("第" + cell.id + "列"));
row.appendChild(cell);
}
tbody.appendChild(row);
}
table.appendChild(tbody);
document.body.insertBefore(table,t1);
}
Firstnamesd | Lastname |
---|---|
Peter | Griffin |
value="Alert innerHTML of table row" />