Table DOM fonctionne sous FF mais pas IE7
Bonjour,
J'ai fais un petit exemple pour tester la création de table via DOM afin de me former sur cette technique.
La table est bien affiché sous FF (3) mais je n'ai rien sous IE7
Voici mon code (un copier coller si vous souhaité le tester).
Je ne vois pas ce qui cloche.....
Pourriez m'aider ?
Merci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
<html>
<head>
<script>
function tst() {
var e= document.getElementById('d2');
var MyTab = document.createElement('table');
MyTab.style.backgroundColor ="red";
MyTab.style.border="4";
MyTab.id ="EventTable";
var tr = document.createElement("tr");
var td = document.createElement("td")
td.appendChild( document.createTextNode("Cel1") );
tr.appendChild( td );
MyTab.appendChild(tr);
td = document.createElement("td");
td.appendChild( document.createTextNode("cel2") );
tr.appendChild( td );
MyTab.appendChild(tr);
e.appendChild(MyTab);
}
</script>
</head>
<body>
<div id="d1">
<input type="button" value="click" onclick="tst();"/>
</div>
<div id="d2">
</div>
</body>
</html> |