Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript DOM Scripting By Example Adding and Removing Names RSVP Checkbox

Why is nothing happening?

I have written all this code down, and the class has been changed to 'responded' but the list item does not get any styling can someone help and explain why this is?

const form = document.querySelector('#registrar');
const input = form.querySelector('input');
const ul = document.querySelector('#invitedList');
const li = document.createElement('li');

form.addEventListener('submit', function submit(name) {
  const text = input.value;
  input.value = '';
  li.textContent = text;
  const label = document.createElement('label');
  label.textContent ='Confirmed';
  const checkbox = document.createElement('input');
  checkbox.type = 'checkbox';  
  input.value = '';

ul.addEventListener('change', function styling(e) {
  const checkbox = e.target;
  const checked = e.checked;
  const listItem = checkbox.parentNode.parentNode;
  if (checked) {
    listItem.clasName = 'responded';
  } else {
    listItem.className = '';

1 Answer

There are two things to fix in ul.addEventListener

const checked = e.checked;

should be

const checked = e.target.checked;


listItem.clasName = 'responded';

should be

listItem.className = 'responded';

Thank you! Can't believe I spent so much time trying to find out what was wrong only to find out they were typos! :-)