Skip to content

Instantly share code, notes, and snippets.

@nus
Created March 29, 2011 13:06
Show Gist options
  • Save nus/892316 to your computer and use it in GitHub Desktop.
Save nus/892316 to your computer and use it in GitHub Desktop.
Javascriptでtableを操作
<html>
<head>
<title>javascript table</title>
<script type="text/javascript">
function onload()
{
var table = document.getElementById("t");
for(var i = 0; i < 20; i++ ) {
var row = table.insertRow(-1);
var number = row.insertCell(-1);
var content = row.insertCell(-1);
number.innerHTML = i + 1;
content.innerHTML = "a";
}
}
</script>
</head>
<body onload="onload()">
<p>javascriptでtableを操作</p>
<table border="4" id="t">
<tr>
<th>No.</th>
<th>内容</th>
</tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment