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

Save button not working

Hi all,

Everything works on the code for this video for me except the save button...any suggestions? It seems to exactly match what Guil has in the video, but maybe i'm missing something?

else if (button.textContent === "save") {
      //select the input of changed name text
      const input = li.firstElementChild;
      //create span element to replace the input with
      const span = document.createElement("span");
      span.textContent = input.value;
      //place new span element before the input & then remove the child input
      li.insertBefore(span, input);
      li.removeChild(input);
      //set button text to "Edit" after clicking save
      button.textContent = "Edit";
    }

Thanks!

Brendan

1 Answer

Steven Parker
Steven Parker
231,236 Points

Text comparisons are case-sensitive. Perhaps the test for "save" doesn't work because the legend on the button is "Save" (with a capital "S")?

You had it Steven, man you are on it! Knocking out answers left and right, seen your name a lot...thanks again, that did it!