Advertisement
1xptolevitico69

Javascript loop counter

Dec 10th, 2021
1,347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.17 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.   <meta charset="UTF-8">
  6.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8.   <title>Javascript loop counter</title>
  9.   <style>
  10.     body {
  11.       margin: 0;
  12.       background-color: ivory;
  13.     }
  14.  
  15.     .header {
  16.       text-align: center;
  17.       font-family: Arial;
  18.       font-size: 70px;
  19.       color: maroon;
  20.     }
  21.  
  22.     #h1 {
  23.       font-family: Arial;
  24.       font-size: 100px;
  25.       text-align: center;
  26.       transform: translateY(80px)scaleY(2);
  27.       color: darkgreen;
  28.     }
  29.  
  30.     button {
  31.       background-color: snow;
  32.       position: absolute;
  33.       top: 10px;
  34.       left: 10px;
  35.       cursor: pointer;
  36.       padding: 0;
  37.       width: 220px;
  38.       border-radius: 5px;
  39.     }
  40.  
  41.     span {
  42.       display: inline-block;
  43.       transform: translate(-10px, -10px);
  44.       font-family: verdana;
  45.       font-weight: 900;
  46.       font-size: 40px;
  47.       color: red;
  48.     }
  49.  
  50.     img {
  51.       height: 60px;
  52.       transform: translate(-10px, 5px);
  53.     }
  54.  
  55.      a {
  56.       position: absolute;
  57.       right: 10px;
  58.       top: 10px;
  59.       text-decoration: none;
  60.       font-size: 20px;
  61.       font-family: verdana;
  62.       color: white;
  63.       background-color: red;
  64.       padding: 5px 20px;
  65.       line-height: 50px;
  66.     }
  67.  
  68.  
  69.   </style>
  70. </head>
  71.  
  72. <body>
  73.     <a href='https://www.youtube.com/channel/UCI875fP1d6RdkZje7R-9ieQ'>YouTube Channel</a>
  74.  
  75.  
  76.   <h1 class='header'>Javascript <br /> Counter Loop</h1>
  77.   <button id='bt_pause' onclick='pause()'><img src='https://1xpto.netlify.app/Icons/menu.png'><span>STOP</span></button>
  78.   <button id='bt_play' onclick='play()'><img src='https://1xpto.netlify.app/Icons/menu.png'><span>START</span></button>
  79.  
  80.   <h1 id='h1'></h1>
  81.  
  82.   <script>
  83.     i = 0;
  84.  
  85.     function play() {
  86.       x = setInterval(count, 100);
  87.       bt_play.style.display = 'none';
  88.  
  89.       function count() {
  90.         h1.innerHTML = i;
  91.         i++;
  92.         if (i > 50) {
  93.           i = 0;
  94.         }
  95.       }
  96.     }
  97.  
  98.     function pause() {
  99.       clearInterval(x);
  100.       bt_play.style.display = 'block';
  101.     }
  102.   </script>
  103. </body>
  104.  
  105. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement