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 trialAnder Bil
Full Stack JavaScript Techdegree Student 6,480 PointsPractice 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
231,236 PointsYou 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.
Ander Bil
Full Stack JavaScript Techdegree Student 6,480 PointsAnder Bil
Full Stack JavaScript Techdegree Student 6,480 Pointsthanks for your help !