Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Javascript loop counter</title>
- <style>
- body {
- margin: 0;
- background-color: ivory;
- }
- .header {
- text-align: center;
- font-family: Arial;
- font-size: 70px;
- color: maroon;
- }
- #h1 {
- font-family: Arial;
- font-size: 100px;
- text-align: center;
- transform: translateY(80px)scaleY(2);
- color: darkgreen;
- }
- button {
- background-color: snow;
- position: absolute;
- top: 10px;
- left: 10px;
- cursor: pointer;
- padding: 0;
- width: 220px;
- border-radius: 5px;
- }
- span {
- display: inline-block;
- transform: translate(-10px, -10px);
- font-family: verdana;
- font-weight: 900;
- font-size: 40px;
- color: red;
- }
- img {
- height: 60px;
- transform: translate(-10px, 5px);
- }
- a {
- position: absolute;
- right: 10px;
- top: 10px;
- text-decoration: none;
- font-size: 20px;
- font-family: verdana;
- color: white;
- background-color: red;
- padding: 5px 20px;
- line-height: 50px;
- }
- </style>
- </head>
- <body>
- <a href='https://www.youtube.com/channel/UCI875fP1d6RdkZje7R-9ieQ'>YouTube Channel</a>
- <h1 class='header'>Javascript <br /> Counter Loop</h1>
- <button id='bt_pause' onclick='pause()'><img src='https://1xpto.netlify.app/Icons/menu.png'><span>STOP</span></button>
- <button id='bt_play' onclick='play()'><img src='https://1xpto.netlify.app/Icons/menu.png'><span>START</span></button>
- <h1 id='h1'></h1>
- <script>
- i = 0;
- function play() {
- x = setInterval(count, 100);
- bt_play.style.display = 'none';
- function count() {
- h1.innerHTML = i;
- i++;
- if (i > 50) {
- i = 0;
- }
- }
- }
- function pause() {
- clearInterval(x);
- bt_play.style.display = 'block';
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement