JavaScript CreateElement Div
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> CreateElement </title>
<script type="text/javascript">
function CreateElement()
{
var newE = document.createElement("DIV");
newE.id = "div2";
newE.innerHTML = "this is a test div " + new Date() + "<br/>";
newE.style.borderStyle = "solid";
newE.style.borderColor = "Red";
newE.style.borderWidth = "1px";
//document.getElementById("div1").appendChild(newE);
document.getElementById("div1").insertBefore(newE,null);
//document.body.appendChild(newE);
}
</script>
</head>
<body>
<input id="Button1" type="button" value="CreateElement" onclick="CreateElement();" />
<input id="Button2" type="button" value="Get" onclick="GetElement();" /><br /><br />
<div id="div1" style="border-style: solid; border-color: Green; border-width: 1px; padding:5px;"> this is a div </div>
</body>
</html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> CreateElement </title>
<script type="text/javascript">
function CreateElement()
{
var newE = document.createElement("DIV");
newE.id = "div2";
newE.innerHTML = "this is a test div " + new Date() + "<br/>";
newE.style.borderStyle = "solid";
newE.style.borderColor = "Red";
newE.style.borderWidth = "1px";
//document.getElementById("div1").appendChild(newE);
document.getElementById("div1").insertBefore(newE,null);
//document.body.appendChild(newE);
}
</script>
</head>
<body>
<input id="Button1" type="button" value="CreateElement" onclick="CreateElement();" />
<input id="Button2" type="button" value="Get" onclick="GetElement();" /><br /><br />
<div id="div1" style="border-style: solid; border-color: Green; border-width: 1px; padding:5px;"> this is a div </div>
</body>
</html>