To remove the p
element from the body
, start by coding bodyElement
, followed by the removeChild()
instruction.
<body id="parent">
<h2>Facebook</h2>
<p id="child">Meg: Movie later?</p>
<script>
var bodyElement = document.getElementById("parent");
var paragraph = document.getElementById("child");
bodyElement.removeChild();
</script>
</body>
Then, remove paragraph
from bodyElement
by coding paragraph
between the parentheses.
<body id="parent">
<h2>Facebook</h2>
<p id="child">Meg: Movie later?</p>
<script>
var bodyElement = document.getElementById("parent");
var paragraph = document.getElementById("child");
bodyElement.removeChild(paragraph);
</script>
</body>