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 trialmusab abdi
7,110 Pointsjavascript
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
musab abdi
7,110 Points@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
Joseph Yhu
PHP Development Techdegree Graduate 48,637 Points-
class='move down'
are two separate classes,move
anddown
; I think you meant it to be a single class, something likemoveDown
. Similarly forclass='move up'
. - Fixing the above and deleting
textContent
fromilk.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);
}
}
);
musab abdi
7,110 PointsJoseph Yhu see if you can help me solve this
Joseph Yhu
PHP Development Techdegree Graduate 48,637 PointsJoseph Yhu
PHP Development Techdegree Graduate 48,637 PointsCould you provide us with the code first?