1function generateRandomColor() {
2 var letters = '0123456789ABCDEF';
3 var color = '#';
4 for (var i = 0; i < 6; i++) {
5 color += letters[Math.floor(Math.random() * 16)];
6 }
7 return color;
8}
9
10var randomColor=generateRandomColor();//"#F10531"
1//Javascript
2function randomColor(){
3 var color = "#";
4 var randomHex = "123456ABCDEF";
5 for(var i = 0; i<6;i++){
6 color+= randomHex[Math.floor(Math.random()*16)]
7 }
8
9 return color;
10}
11
12var mytimer ;
13
14function setColor(){
15
16 $("body").css("background-color", randomColor);
17}
18
19var mytimer = setInterval(setColor, .8000);
20// html
21!DOCTYPE html>
22<html>
23 <head>
24 <title>Page Title</title>
25 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
26
27 </head>
28 <body>
29
30 //include javascript file.
31 </body>
32</html>