Ask coding questions

← Back to all posts
How to make rgb text
indigiz (9)

I want the Socket text to be rgb. Just send me code and where to put it. Thanks!

Comments
hotnewtop
themining72 (49)

setInterval(() => {document.getElementById("Title").style.color = "#" + Math.floor(Math.random()*16777215).toString(16);}, 50);

Put this in anywhere in html/script.js. You may adjust the flashing speed by editing the 50 in the final parts of the code, the smaller the faster but may stop for a few seconds from lag.

themining72 (49)

@indigiz Uhh I think your site is currently broken but the script loaded before the Title element, so it's trying to make it rgb before the element existed. You could try to remove <script src = "script.js"></script> (Line 8, html/index.html) from the head and put it in body just above </body> (Line 43, html/index.html), or alternatively (possibly better) replace the previous code I gave you with:

window.addEventListener('load', function () {
  setInterval(() => {document.getElementById("Title").style.color = "#" + Math.floor(Math.random()*16777215).toString(16);}, 50);
})

in html/script.js or maybe try the answer by the other person.