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 DOM Scripting By Example Improving the Application Code Next Steps

I'm struggling to implement the select element into my code.

I'm just failing to understand how to manipulate the select element to, 1. select a value 2. implement it into the createLi() function. my google search are leaving me confused at the moment

Steven Parker
Steven Parker
240,995 Points

Please show the code you are working with.

This is a link to the repo [https://github.com/TobiFarore/rsvp]

1 Answer

Steven Parker
Steven Parker
240,995 Points

In app.js, on line 119:

        if (select) {                           // old: this only checks that "select" exists
        if (select.value != "Not Responded") {  // fix: this checks if a response was selected

And before assuming that the change event was triggered by the select, you should check the tag like you do for "BUTTON" on line 127.

Thank you, updated the handler

``` ul.addEventListener('change', (e) => { if ( e.target.tagName === 'SELECT') { const select = e.target; const listItem = select.parentNode;

    if (select.value != 'Not Responded') {
        listItem.className = 'responded';
    } else {
        listItem.className = '';
    }
}
}); ```