<html>
<head>
<title> Add child elements of Div</title>
<script type="text/javascript">
function addChildElements()
{
var newdiv=document.createElement("div");
var newtext=document.createTextNode("Label div :");
var aTextBox=document.createElement('input');
aTextBox.type = 'text';
aTextBox.value = 'Input Element';
aTextBox.id = 'txt_cell_two_';
newdiv.appendChild(newtext); //append text to new div
newdiv.appendChild(aTextBox); //append text to new div
document.getElementById("test").appendChild(newdiv); //append new div to another
}
</script>
</head>
<body>
<input type="button" value="Add Child Element" onclick="addChildElements()"/>
<div id="test"></div>
</body>
</html>
|
My Blog Title
|