我只是想创建一个简单的javascript函数来输出一个小表但似乎无法让它工作。
<html>
<head>
<meta charset ="utf-8">
<title>Test Table</title>
<script type = text/javascript>
function drawTable()
{
var tableDiv = document.getElementById( "numbersTable" );
tableDiv.innerHTML = "<table>" +
"<caption>Numbers Table</caption>" +
"<thead><th>Number</th><th>Square</th><th>Cube</th></thead>" +
"<tbody><tr><td>1</td><td>2</td><td>3</td></tr>" +
"</tbody></table>";
}
</script>
</head>
<body>
<div id = "numbersTable"></div>
</body>
任何人都可以看到问题所在吗?
答案 0 :(得分:3)
drawTable()
<div id="numbersTable"></div>