JavaScript DHTML/Node Operation/createElement
Append paragraph tag to body tag
<html>
<head>
<title>Location</title>
<script type = "text/javascript">
function showProps() {
var body = document.getElementsByTagName("body")[0];
for (var prop in location) {
var elem = document.createElement("p");
var text = document.createTextNode(prop + ": " + location[prop]);
elem.appendChild(text);
body.appendChild(elem);
}
}
</script>
</head>
<body onload="showProps()">
</body>
</html>
"createElement()" Example
<html>
<body>
<script language="javascript">
function function1(){
var myElement = document.createElement("<hr>");
myBody.appendChild(myElement);
}
</script>
<body id="myBody">
<button onClick="function1();">Put horizontal rule</button>
</body>
</html>