About Me

My photo
I am a college student and is taking up Bachelor of Science in Information Technology . I am with my family . I love my family , we leave a simple life . I lost my father when I was just a kid . But i am very lucky to have my stepfather . He treated us as his own . I also love my mother eventhough she has a noisy mouth . :) I have a KONTRABIDA FOREVER SISTER . Blissy and KILL JOY FOREVER SISTER . Dada . I hope i can help them someday :)

Sunday, August 8, 2010

Adding and Removing Nodes

<html>
<title>Adding and Removing nodes</title>
<script language="JavaScript">

function AddNode(tag){
if(!document.getElementById)
return;
element= document.createElement(tag);
if(tag!='HR'){
txt= document.form1.newtext.value;
element.innerHTML = txt;
}
s= document.getElementById("adhere");
s.appendChild(element);
}

function DeleteNode(){
if(!document.getElementById)
return;
s= document.getElementById("adhere");
s.removeChild(s.lastChild);
}

</script>
</head>
<body>
<h1>Adding and Removing Nodes</h1>
<p>Enter some text and use the buttons below to add or remove nodes from this page's DOM hierarchy</p>
<span ID ="adhere"></span>
<form name="form1" ID="form1">
<input type="text" name="newtext" size="70"><br>
<input type="button" value="Add Paragraph" onClick="AddNode('P');">
<input type="button" value="Add Heading" onClick="AddNode('H3');">
<input type="button" value="Add Line" onClick="AddNode('HR');">
<input type="button" value="Deleteanode" onClick="DeleteNode();">
</form>
</body>
</html>

 



                                       OUTPUT


Picture3

No comments:

Post a Comment