...

View Full Version : setAttribute()



mjs1
06-10-2004, 03:37 PM
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function loaded()
{
// create elements
var table = document.createElement('table');
var tbody = document.createElement('tbody');
var tr_a = document.createElement('tr');
var tr_b = document.createElement('tr');
var td_a = document.createElement('td');
var td_b = document.createElement('td');
var td_c = document.createElement('td');
var text = document.createTextNode('hello world');
// attributes
table.setAttribute('border','1');
td_c.setAttribute('colspan','2'); // ?!?@#$!
// append row 1
td_a.innerHTML = td_b.innerHTML = 'foo';
tr_a.appendChild(td_a);
tr_a.appendChild(td_b);
tbody.appendChild(tr_a);
tbody.appendChild(tr_b);
// append row 2s
td_c.innerHTML = 'bar';
tr_b.appendChild(td_c);
table.appendChild(tbody);
document.getElementById('target').appendChild(table);
};
</script>
</head>

<body onload="loaded();">
<div id="target"></div>
</body>
</html>

WA
06-10-2004, 09:17 PM
Hi:
Please edit your thread and more clearly state the nature of it. Is this a question? Thanks,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum