0
EROR When trying to wear ramdom ()
I want to change the color on each element P with Random Methods but an error can get helped me to fix this error? https://code.sololearn.com/WHg2K4jApQ52/?ref=app
5 Respostas
+ 2
try using:
Math.random()*255
instead of
random(255)
+ 3
In your JS section:
window.onload = function(){
const texts = document.querySelectorAll(".container p");
let randomColors = function(){
let limit = texts.length;
for(i = 0; i < limit; ++i) {
texts[i].style.color = "rgb(" + Math.floor(Math.random()*256) + "," + Math.floor(Math.random()*256) + "," + Math.floor(Math.random()*256) + ")";
}
}
setInterval(randomColors,1500);
}
+ 3
hafizd21j You're welcome : )
+ 1
thanks Ipang now I know the method is better than what I used before
+ 1
👍👍👍👍