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

Joseph Quintiliano
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Quintiliano
Front End Web Development Techdegree Graduate 14,338 Points

I dont understand the concept of a function in the video

function attachRemoveButton(li){ let remove = document.createElement('button'); remove.className = 'remove'; remove.textContent = 'Remove'; ***li.appendChild(remove)** }

What i do not understand is why or even how we are appending an element like a button to a list item. i would understand if I had been asked to append a new an LI element to a UL element... but to append a button elemtn to a LI element doesnt visually sit right with me. Could someone please help me digest this better

2 Answers

Steven Parker
Steven Parker
229,582 Points

A list item can contain many different kinds of things, buttons included. You forgot to provide a link to it, but didn't the video show what the screen looks like with the button added?

Steven Parker
Steven Parker
229,582 Points

Joseph Quintiliano — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!