Javascript background color changes on time
Background color test
Script
Function setcolor ()
{
Var colorString;
Do {
ColorString = "#" + Math. floor (Math. random () * Math. pow (2, 24). toString (16 );
}
While (colorString. length <7 );
Document. getElementById ("myp"). style. backgroundColor = colorString;
SetTimeout (setcolor, 100 );
}
Script
<Head> </pead> <body onload = "setcolor ()"> <p id = myp style = "font: 12px sans-serif; width: 300px; height: 200px; "> Background color test </p> script function setcolor () {var colorString; do {colorString =" # "+ Math. floor (Math. random () * Math. pow (2, 24 )). toString (16);} while (colorString. length <7); document. getElementById ("myp "). style. backgroundColor = colorString; setTimeout (setcolor, 100);} script </body>
[Ctrl + A Select All Note: If you need to introduce external Js, you need to refresh it to execute]