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


Dom Manipulation

Hi Friends,

I am working on the RSVP Dom Scripting course. I am hung up and handling the events when a user edits a name. After the 'save' button is clicked the entire element is removed. If I inspect the element in Chrome Dev tools I can see the correct value is there but it is not showing up on the page.

Below is a snapshot of my workspace.


ul.addEventListener('click', (e) => {
    if (e.target.tagName === 'BUTTON'){
        const li = e.target.parentNode;
        const ul = li.parentNode;
        const button = e.target;
        if (button.textContent === 'remove'){
        }else if (button.textContent === 'edit'){
            const span = li.firstElementChild;
            const input = document.createElement('input');
            input.type = 'text';
            input.value = span.textContent;
            li.insertBefore(input, span);
            button.textContent = 'save';
        }else if ( button.textContent === 'save'){
            const input = li.firstElementChild;
            const span = document.createElement('input');
            span.textContent = input.value;
            li.insertBefore(span, input);
            button.textContent = 'save';

1 Answer

Hey Brooks Johnson if you look at line 88, your span aka input doesn't have a property of textContent, thats only for h2, spans, p, etc, for <input> you want to use value

span.value = input.value;

//instead of
span.textContent = input.value;

perfect thank you

no worries, be sure to mark answered for the next person with the same question