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 trialJORGE HERRANDO GARIJO
7,895 PointsKeeping the color on the first and last li
Hello. My first and last li have a backgroundColor defined. I am trying to keep the color always in the first and last li even when I change the position. I managed to get the color to the new first-last li, but I cannot make it disappear from the previous one. For any reason, the for loop doesn't go through the list items, yet the console says the backgroundColor it's been changed... Any suggestions?
1 Answer
Steven Parker
231,268 PointsThe "backgroundColor" should be a sub-property of the "style" and not a property of the element itself. And you probably want to just remove the color instead of making it black:
// lis[i].backgroundColor = 'black';
lis[i].style.backgroundColor = ''; // fixed
JORGE HERRANDO GARIJO
7,895 PointsJORGE HERRANDO GARIJO
7,895 PointsThose little bugs!!
Yeah I was trying black just to let me see if it was working.
Thank youuu!