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 trialSAMUEL LAWRENCE
Courses Plus Student 8,447 Pointswoohooooo, I did it.
Woo hoo, I did it. I don't know if it's ok to post this here since it's not a question, but it's a solution so here goes. I was able to figure out the solution to implement a saved state
and it works so nicely. I'm so elated right now. woo hoo. here is the app. Since there is a lot of code I'm just sharing the part I wrote.
else if (button.textContent === 'save') {
const input = li.firstElementChild;
const newName = document.createElement('span');
newName.textContent = input.value;
li.insertBefore(newName, input);
li.removeChild(input);
button.textContent = 'edit';
}
So I took Guil Hernandez hint and undid everything we did to add the edit input field.
- I first select the input using the first element child property.
- Next I created the span element I wanted to replace the input with.I called it newName.
- I then set it's text content to be the value of the input.
- I used the input to place the new span element into the DOM using insert before.
- I called removeChild on the input to remove it.
- finally I changed the button's text content to say edit, which is what it was in the original state.
Woooooo!!! Sorry guys I'm just excited.
Oh I forgot to mention, I DIDN'T LOOK AT THE SOLUTION VIDEO!
1 Answer
Guil Hernandez
Treehouse TeacherWell done, SAMUEL LAWRENCE. It feels great when things begin to click. Congrats! :)
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsIt sure does. Thanks for the reply Guil Hernandez . Means a lot man.
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsSAMUEL LAWRENCE
Courses Plus Student 8,447 PointsI had to mention that I didn't look at the video, because after I looked at the video, Guil Hernandez code was exactly like mines. lol. That's a first.