var colourArray = [
"rgb(248, 155, 165)",
"rgb(248, 160, 170)",
"rgb(248, 160, 180)",
"rgb(248, 175, 195)",
"rgb(249, 184, 195)",
"rgb(248, 195, 215)",
"rgb(248, 205, 235)",
"rgb(248, 225, 225)",
"rgb(248, 116, 138)",
];
changingColorsArray = [...colourArray];
function arrayRotate(arr, reverse) {
if (reverse) arr.unshift(arr.pop());
else arr.push(arr.shift());
return arr;
}
var banner = document.getElementsByClassName('banner')[0].innerHTML
var bannerArray = banner.split('')
function applyColors(letters, colorArr) {
for (let i = 0; i < letters.length; i++) {
letters[i].style.color = colorArr[i];
}
}
myInterval = setInterval(() => {
arrayRotate(changingColorsArray, true);
applyColors(bannerArray, changingColorsArray);
}, 1600);
My html
<div class="banner">Funny Klock</div>
so far ive gathered that letters[i]
is accessing an index of an array
letters[i].style.color = colorArr[i];
hence cannot set the property of that item, unlike a span, div or class, PLEASE tell me if im right.
Plus, how would you access the color property and loop through the innerhtml to give each letter a different color