This code works fine in FF and NS. Shows nice red letters. In IE the style is not applied. Any ideas?
Thanks
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>AppendStuff</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">
<!--
function newDIV() {
var myEle = document.createElement('div');
return myEle;
}
function addAttr(obj, prop, val) {
obj.setAttribute(prop, val);
return obj;
}
function addText(obj, text) {
var myText = document.createTextNode(text);
return addEle(obj, myText);
}
function addEle(container, content) {
container.appendChild(content);
return container;
}
function make() {
var myBody = document.getElementsByTagName("body")[0];
var myDiv = newDIV();
myDiv = addAttr(myDiv, 'style','color:red');
myDiv = addText(myDiv, 'DEMO');
myBody = addEle(myBody, myDiv);
}
-->
</script>
</head>
<body>
<button onclick="make()">TEST</button>
</body>
</html>
Thanks