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