JORGE HERRANDO GARIJO7,895 Points
Keeping 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?
Steven Parker177,725 Points
The "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