Posts: 850
Name: Matt Pealing
Location: England, north west
|
It doesn't pop up with an error message, it's just that the table just doesn't appear
Code:
function tableBuild ()
{
var container = document.getElementById ('container');
// build head
var headName = document.createTextNode ('Name');
var headAge = document.createTextNode ('Age');
var th1 = document.createElement ('th');
var th2 = document.createElement ('th');
var tr = document.createElement ('tr');
var table = document.createElement ('table');
// append
th1.appendChild (headName);
tr.appendChild (th1);
table.appendChild (tr);
container.appendChild (table);
alert (table.nodeName);
}
window.onload = tableBuild;
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="ajaxStudent.js"></script>
</head>
<div id="container">
This is the container
</div>
<body>
</body>
</html>
It works okay in FF (surprisingly). Also, when I alert the nodeName, even IE recgnises it as a table, so I don't know why it isn't displaying it?
Last edited by pealo86; 02-04-2009 at 09:49 AM..
|