<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<style>
table {
border-collapse: collapse;
}
table td {
border: 1px solid #111;
padding: 2px;
}
</style>
</head>
<body>
<script>
var col = 2;
var row = 4;
document.body.innerHTML = "<table></table>";
for (var i = 0; i < row; ++i) {
document.getElementsByTagName("table").innerHTML += "<tr></tr>";
for (var j = 0; j < col; ++j) {
document.getElementsByTagName("tr").innerHTML += "<td>1</td>";
}
}
</script>
</body>
</html>
|