Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Ander Bil
seal-mask
.a{fill-rule:evenodd;}techdegree
Ander Bil
Full Stack JavaScript Techdegree Student 3,342 Points

Practice manipulating the DOM - delete button does not show up

hello, I am doing a task exactly the way as the teacher did it, but changes are not being reflected on the chrome browser:

const deletebutton = document.createElement('button'); deletebutton.textContent = "Delete";

const extra = document.querySelector('.extra');

extra.appendChild('deletebutton');

so, the variables and objects above should create a button with a delete message on it. however, it is not showing up. I have already saved my work and refreshed mybrowser.

However, I can see there is an error showing up on the chrome console, it says "Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'."

Please let me know what's wrong thanks!!

1 Answer

Steven Parker
Steven Parker
217,573 Points

You shouldn't put the variable name in quotes, but you should also check to be sure that the element you wish to attach the button to is defined in the HTML with the class "extra".

If you still have trouble, a more complete way to share your code is to make a snapshot of your workspace and post the link to it.