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 trial2 Answers
Steven Parker
231,271 PointsCarlos (and Vic),
Remember that every time an item is moved, you need to check if it is now the edge item and remove the appropriate button if so.
And be aware that if you remove the "up" button from the top item (and I assume the "down" button from the bottom), you'll need to recreate them if those items are moved using the remaining button. You'll also need to recreate them if another item is moved to replace them at the top or bottom of the list.
As an alternative enhancement, I would recommend just setting the button's "disabled" property, which will change the visual appearance in a way most users will recognize as meaning "not active". Then you can just clear that property when the item is moved or another one is moved to take its place.
Carlos Braga
13,587 PointsHi. I have tried to figure it out this challenge and I was able to remove the button Up from the 1st child element and button down from the child element but when the items position the code doesn't follow it. I guess because the button has been already been placed to the item. Anyway, I checked the console and after swapping the order the UL[ ] array also changes. So any suggestion to how implement this change so even swapping the order the button will placed or removed automatically. My code below:
function attachListItemButtons(li) { let up = document.createElement('button'); up.className = 'up'; up.textContent = 'Up'; if (li !== listUl.firstElementChild) { li.appendChild(up); }
let down = document.createElement('button');
down.className = 'down';
down.textContent = 'Down';
if (li !== listUl.lastElementChild) {
li.appendChild(down);
}
let remove = document.createElement('button'); remove.className = 'remove'; remove.textContent = 'Remove'; li.appendChild(remove); }
Steven Parker
231,271 PointsSteven Parker
231,271 PointsThat's not enough information to understand the issue, please describe the issue in more detail.
Plus it looks like you already asked a question about this, and also this question too.