Reputation: 597
I'm just trying to create simple javascript function that outputs a small table but can't seem to get it working.
<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>
Can anyone see where the problem is?
Upvotes: 1
Views: 2226
Reputation: 6381
drawTable()
<div id="numbersTable"></div>
Upvotes: 3