I am currently working on implementing a dark mode feature and I am encountering an issue when trying to change the CSS of multiple elements at once.
This is my JavaScript code:
var elem = document.getElementById('fonts');
for(var i=0; i<elem.length; i++){
elem[i].style.color="#FFFFFF";
console.log(elem[i]);
}
However, nothing seems to be changing. I believe I need to use a loop because there are multiple elements with the same id "fonts". If I try without the loop, only the first one gets affected.
The console isn't showing any errors either. Was there something wrong with how I implemented this?