Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="no">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Tid</title>
- </head>
- <body>
- <button id="btn">TAPP HER</button>
- <button id="btnReset">RESET</button>
- <script>
- var btn = document.getElementById("btn");
- var btnReset = document.getElementById("btnReset");
- var antall = 0;
- var tidenflyr = false;
- function stoppKlokka() {
- tidenflyr = false;
- btn.disabled = true;
- console.log("Stopper klokka");
- // TODO - Registrer antall klikk
- antall = 0; // Reset antall
- }
- function startKlokka() {
- tidenflyr = true;
- // Stopper klokka etter 10 sekunder
- console.log("Starter klokka");
- setTimeout(stoppKlokka, 10000);
- }
- function tell() {
- if(tidenflyr){
- antall++;
- } else {
- startKlokka();
- antall++;
- }
- }
- btn.onclick = tell;
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment