Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Appending and Removing Elements

Halp Plz

No idea how to do something this simple...tried every combination I could think of...forgive my stupidity please (and give a working example plz)

app.js
var body = document.body;
var newParagraph = document.createElement("p");
var pleaseEnableParagraph = document.querySelector("#please_enable");

//Remove "Please Enable JavaScript" paragraph

removeChild.(pleaseEnableParagraph);

//Append new paragaph to document
index.html
<!DOCTYPE html>
<html>
  <body>
    <p id="please_enable">Please Enable JavaScript</p>

    <script src="app.js"></script>
  </body>
</html>

2 Answers

You're just missing one thing; the parent from which you are removing the child! So when you use .removeChild(); you must identify the parent. Have a look at this:

body.removeChild(pleaseEnableParagraph);

Thank you!

You can't just call removeChild() without specifying a parent. Since the please_enable element is a child of body and you already have a variable for that, you can call this and it should work:

body.removeChild(pleaseEnableParagraph);

Thanks!