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

able to change the textNode value to 'confirmed' when checkbx is checked but unable to reverse when chk box in unchecked

ulList.addEventListener('change', (e) => {


        if (e.target.checked) {

           e.target.parentNode.parentNode.className = 'responded';

            let chkBx = e.target;
            console.log(e.target.checked);
            let labList = e.target.parentNode.childNodes;

              // create a function to get the children of the label ele which is a nodelist and loop 
     through (as  other nodes can be added later, so for loop is better than targeting any 
      node)

              for (let i = 0; i <labList.length; i+=1) {

                let labChild = labList[i];

                f(labChild.nodeType == 3 && labChild.nodeValue == 'confirm') {

               labChild.nodeValue ='confirmed';

               }else if(labChild.nodeValue == 'confirmed' && e.target.checked == false) {


                    labChild.nodeValue ='confirm';

                      }

                  }

              }else{

             e.target.parentNode.parentNode.className = '';

        }

});