Remove node from another node in Javascript in JavaScript
Description
The following code shows how to remove node from another node in Javascript.
Example
<!DOCTYPE html>
<html>
<body>
<div id="div1">
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul><!--from ww w . java 2 s.c o m-->
</div>
<p id="p1">Hello <b>World!</b></p>
<script type="text/javascript">
var div = document.getElementById("div1");
var p = document.getElementById("p1");
var formerFirstChild = div.removeChild(div.firstChild);
document.writeln(formerFirstChild);
</script>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Delete
Remove a child element from a HTML element ...
Remove a child element from a HTML element ...