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>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。