Advertisement
Guest User

index

a guest
Nov 25th, 2017
646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.46 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  4. <script src="scripts/jquery-3.2.1.min.js"></script>
  5. <style>
  6.     /* K6ik stiilid on siin */
  7.  
  8.     header {
  9.         color: aquamarine;
  10.     }
  11.  
  12.     td {
  13.         width: 17vw;
  14.         height: 17vw;
  15.     }
  16.    
  17.     button{
  18.         margin-top: 2vh;
  19.     }
  20. </style>
  21.  
  22. <body>
  23.     <center>
  24.         <!-- Veebilehe kood l2heb siia -->
  25.         <h1>Clicker Game</h1>
  26.         <p>Score: <text>0</text></p>
  27.         <table border="1">
  28.             <tr>
  29.                 <td id="11"></td>
  30.                 <td id="12"></td>
  31.                 <td id="13"></td>
  32.                 <td id="14"></td>
  33.                 <td id="15"></td>
  34.             </tr>
  35.             <tr>
  36.                 <td id="21"></td>
  37.                 <td id="22"></td>
  38.                 <td id="23"></td>
  39.                 <td id="24"></td>
  40.                 <td id="25"></td>
  41.             </tr>
  42.             <tr>
  43.                 <td id="31"></td>
  44.                 <td id="32"></td>
  45.                 <td id="33"></td>
  46.                 <td id="34"></td>
  47.                 <td id="35"></td>
  48.             </tr>
  49.             <tr>
  50.                 <td id="41"></td>
  51.                 <td id="42"></td>
  52.                 <td id="43"></td>
  53.                 <td id="44"></td>
  54.                 <td id="45"></td>
  55.             </tr>
  56.             <tr>
  57.                 <td id="51"></td>
  58.                 <td id="52"></td>
  59.                 <td id="53"></td>
  60.                 <td id="54"></td>
  61.                 <td id="55"></td>
  62.             </tr>
  63.         </table>
  64.        
  65.         <button>Start</button>
  66.     </center>
  67. </body>
  68.  
  69. <script>
  70.     function getRandomSquareId() {
  71.         let min = 1;
  72.         let max = 5;
  73.         let x = Math.floor(Math.random() * max) + min;
  74.         let y = Math.floor(Math.random() * max) + min;
  75.         return y.toString() + x.toString();
  76.     }
  77.  
  78.     function clearTheBoard() {
  79.         for (let y = 1; y <= 5; y++) {
  80.            for (let x = 1; x <= 5; x++) {
  81.                let id = "#" + y.toString() + x.toString();
  82.                $(id).css("background-color", "white");
  83.            }
  84.        }
  85.    }
  86.    
  87.    function renewPointSquare(){
  88.        clearTheBoard();
  89.        let randomID = getRandomSquareId();
  90.        $("#" + randomID).css("background-color", "red");
  91.    }
  92.    
  93.  
  94.    $("td").click(function() {
  95.        alert("Background: " + $(this).css("background-color"));
  96.    });
  97. </script>
  98.  
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement