Javascript stopwatch
How do I make an javascript stopwatch?
What is a javascript stopwatch? How do you make a javascript stopwatch? This script and codes were developed by Dave DeHaan on 04 January 2023, Wednesday.
Javascript stopwatch - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>javascript stopwatch</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <center>
<div id="stopwatch"> <span id="minute">00</span><span id="second">00</span><span id="ms">00</span> <br /> <button id="start" onclick="start();">start</button> <button id="stop" onclick="stop();">stop</button>
</div>
</center> <script src="js/index.js"></script>
</body>
</html>
Javascript stopwatch - Script Codes CSS Codes
body { font-family: arial;
}
#stopwatch { width: 200px; height: 100px; background: #CCC; color: #333; border: solid 2px #333; border-radius: 150px; padding: 60px 50px 100px; text-align: center; font-size: 30px;
}
#stopwatch span { background: #fff; padding: 3px; border-radius: 5px; border: solid 2px #333; margin: 3px; display: inline-block;
}
#stopwatch button:first-of-type { margin-top: 25px;
}
#stopwatch button { font-size: 20px; -webkit-appearance: none; border: solid 2px #333; background: #fff; color: #333; border-radius: 5px; width: 100px; margin-top: 5px; transition: .3s;
}
#stopwatch button:hover { border: solid 2px #fff; background: #333; color: #fff; cursor: pointer;
}
Javascript stopwatch - Script Codes JS Codes
var timer = 0;
var timerInterval;
var ms = document.getElementById('ms');
var second = document.getElementById('second');
var minute = document.getElementById('minute');
function start() { stop(); timerInterval = setInterval(function() { timer += 1/60; msVal = Math.floor((timer - Math.floor(timer))*100); secondVal = Math.floor(timer) - Math.floor(timer/60) * 60; minuteVal = Math.floor(timer/60); ms.innerHTML = msVal < 10 ? "0" + msVal.toString() : msVal; second.innerHTML = secondVal < 10 ? "0" + secondVal.toString() : secondVal; minute.innerHTML = minuteVal < 10 ? "0" + minuteVal.toString() : minuteVal; }, 1000/60);
}
function stop() { clearInterval(timerInterval);
}
Developer | Dave DeHaan |
Username | davedehaan |
Uploaded | January 04, 2023 |
Rating | 3 |
Size | 2,102 Kb |
Views | 16,192 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
404 Glitch Effect | 3,495 Kb |
Spotlight Search 404 | 3,033 Kb |
Randomly generated canvas clouds | 2,028 Kb |
Tween Bubbles. | 2,175 Kb |
Unblur on Page Load | 2,048 Kb |
Winter | 2,613 Kb |
Dynamic Hero Image | 2,435 Kb |
Merry Christmas. | 3,030 Kb |
Christmas Countdown | 2,133 Kb |
Asteroids | 2,846 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Octopus Bar iPad App Interactions | Davidkpiano | 6,735 Kb |
Header Line Issue | Charlie-volpe | 1,768 Kb |
CSS eye follow | Pedrocampos | 2,592 Kb |
SVG Scalable Text | Said_FD | 1,451 Kb |
Pictos font library from CodePen | Jstam | 3,790 Kb |
Feedback Page | TessDiNapoli | 2,836 Kb |
Background Images | Jooonebug | 2,100 Kb |
Ball Physics | Getsetbro | 3,149 Kb |
Pure CSS Read More Arrow | Zephyr | 1,747 Kb |
Twitch | SarahDunlap | 2,937 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!