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

javascript

can any please help me correct this code in away that the <li> elements text content change its color to red when the button is clicked and the last button when clicked it shows null....your help is highly appreciated; the link to my work space is https://w.trhou.se/mujimoq3fv

Could you provide us with the code first?

@Joseph Yhu i have added the link for my workspace...thank for the correction https://teamtreehouse.com/community/why-am-i-getting-this-error-10

2 Answers

  1. class='move down' are two separate classes, move and down; I think you meant it to be a single class, something like moveDown. Similarly for class='move up'.
  2. Fixing the above and deleting textContent from ilk.textContent.style.color='red'; should fix the problem.
const div=document.querySelector('.hideMe');
const moveUp=document.getElementsByClassName('.moveUp');
const moveDown=document.getElementsByClassName('.moveDown');
const input=document.querySelector('.addInput');
const body=div.parentNode;
const addItemButton=document.querySelector('.addItem');
const removeItemButton=document.querySelector('.remove');
//const ul=document.querySelector('.list')
const li=document.querySelector('li')
const head=document.querySelector('.body');
const ul=li.parentNode;


ul.addEventListener('click',(event)=>{
            if(event.target.className==='moveDown'){
              const elementEv= event.target;
              const ilk=elementEv.parentNode;
              const nextElm=ilk.nextElementSibling;
              ilk.style.color='red';
              const parentElm=ilk.parentNode;
              parentElm.insertBefore(nextElm,ilk);
             }

}        

                    );

Joseph Yhu see if you can help me solve this