How can I change colors randomly without reloading ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I change colors randomly without reloading ?

I tried to change the background colors of a paragraph but I can only change it once. I have to reload in order to change it again. How can I do without reloading ? Here is the code, you can check it. https://code.sololearn.com/W3JIWJwCaIch/?ref=app

20th Sep 2019, 5:21 PM
Houssein Elmi Hassan
Houssein Elmi Hassan - avatar
2 Answers
+ 5
Cut html line 70 and 72 and paste them inside the change_color function. Also, random_color should be Math.floor, not Math.ceil.
20th Sep 2019, 5:42 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 2
Hello 🐯 Alex Tusinean 🐤 , thank you 😁. Now it works well.
20th Sep 2019, 6:55 PM
Houssein Elmi Hassan
Houssein Elmi Hassan - avatar