Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <button id="myButton">Press button</button>
- <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
- <script>
- $('#myButton').on('click', setBackground);
- function setBackground() {
- window.setTimeout(setBackground, 1500);
- var index = Math.round(Math.random() * 10);
- var ColorValue = "FFFFFF";
- if (index == 1) ColorValue = "003366";
- if (index == 2) ColorValue = "660066";
- if (index == 3) ColorValue = "FF0000";
- if (index == 4) ColorValue = "FFFF66";
- if (index == 5) ColorValue = "99FF33";
- if (index == 6) ColorValue = "00CC00";
- if (index == 7) ColorValue = "666633";
- if (index == 8) ColorValue = "3D9999";
- if (index == 9) ColorValue = "143333";
- if (index == 10) ColorValue = "1A1A80";
- $("body").css('backgroundColor', "#" + ColorValue);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement