Advertisement
Guest User

Untitled

a guest
Jan 28th, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title></title>
  5. </head>
  6. <body>
  7.  
  8. <button id="myButton">Press button</button>
  9. <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
  10. <script>
  11.     $('#myButton').on('click', setBackground);
  12.  
  13.     function setBackground() {
  14.         window.setTimeout(setBackground, 1500);
  15.  
  16.         var index = Math.round(Math.random() * 10);
  17.  
  18.         var ColorValue = "FFFFFF";
  19.  
  20.         if (index == 1) ColorValue = "003366";
  21.         if (index == 2) ColorValue = "660066";
  22.         if (index == 3) ColorValue = "FF0000";
  23.         if (index == 4) ColorValue = "FFFF66";
  24.         if (index == 5) ColorValue = "99FF33";
  25.         if (index == 6) ColorValue = "00CC00";
  26.         if (index == 7) ColorValue = "666633";
  27.         if (index == 8) ColorValue = "3D9999";
  28.         if (index == 9) ColorValue = "143333";
  29.         if (index == 10) ColorValue = "1A1A80";
  30.  
  31.         $("body").css('backgroundColor', "#" + ColorValue);
  32.     }
  33. </script>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement