JS Countdown Timer
How do I make an js countdown timer?
Simple JS Countdown Timer. What is a js countdown timer? How do you make a js countdown timer? This script and codes were developed by Anthony Young on 31 October 2022, Monday.
JS Countdown Timer - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>JS Countdown Timer</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container">
<div class="title">JS Countdown Timer</div>
<div class="timer"></div>
<div class="timerMsg"></div>
<button>Stop Timer</button>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
JS Countdown Timer - Script Codes CSS Codes
.container { width: 500px; display: block; margin: 50px auto; padding: 10px; outline: 1px black solid;
}
.title { font-size: 20px;
}
.timer { font-size: 25px; min-height: 100px;
}
button { margin-top: 10px;
}
JS Countdown Timer - Script Codes JS Codes
var pad = function one(number, length) { var str = '' + number; while (str.length < length) {str = '0' + str;} return str; }; var formatTime = function(time) { var min = parseInt(time / 60000), sec = parseInt(time / 1000) - (min * 60), hundredths = pad(time - (sec * 1000) - (min * 60000), 2); //return (min > 0 ? pad(min, 2) : "00") + ":" + pad(sec, 2) + ":" + hundredths; return (min > 0 ? pad(min, 2) : "00") + ":" + pad(sec, 2); }; var countdownTimer = function(minutes, funct) { //add a second on 1000 for delay if (minutes) { var startTime = (minutes * 60000) + 1000; } //console.info('Starttime: ',startTime); var endtime = new Date().getTime() + startTime; var handleTime = function four() { //console.log('\nFunc running...\n'); var now = new Date().getTime(); var countdown = formatTime(endtime - now); //console.info('countdown: ', countdown); //check for el if (jQuery('.timer').length) { jQuery('.timer')[0].innerHTML = countdown; } //check if the time has counted down if (endtime - now <= 0) { //clear timeR clearInterval(timeR); //run callback funct(); } }; //every second run the handle time function var timeR = setInterval(handleTime, 1000); //1 second }; var stopTimer = function five(el, min, fn){ el.click(function clickr(){ clearInterval(timeR); countdownTimer(min, fn); }); }; stopTimer(jQuery('button'), 5, functs); countdownTimer(5, functs); var functs = function(){console.log('funct')};
Developer | Anthony Young |
Username | ayoungh |
Uploaded | October 31, 2022 |
Rating | 3 |
Size | 2,435 Kb |
Views | 30,360 |
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 |
Exit Intention JS | 2,356 Kb |
Tags and searching etc | 5,929 Kb |
Field validation | 2,249 Kb |
A Pen by Anthony Young | 1,658 Kb |
Mobile push in nav | 2,605 Kb |
Material header and menu drawer | 3,347 Kb |
React - Table with expanding rows | 6,773 Kb |
Anthony Young - ayoungh.co.uk Material Design mashup | 5,216 Kb |
Keypress check mobile | 1,492 Kb |
Drop down sidebar | 2,616 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 |
Rows with image hover effect | Amit-webdesigner | 12,875 Kb |
Simple animated hover effect | Pobee-norris | 3,044 Kb |
Android Logo with HTML and CSS | Wifi | 2,000 Kb |
Colorful Sliders | Chanrith | 1,246 Kb |
Gulpfile | Aimhigherwebdesign-amy | 1,765 Kb |
Google Chrome Icon using Pure CSS in one DIV | Grssam | 3,627 Kb |
GrcJS | Vino6 | 2,047 Kb |
BenU Maintenance Site | Ksherman | 4,893 Kb |
DFF Website | Hawcubite | 10,123 Kb |
Impress JS Algorhytmic Generator | Jeffscottward | 7,906 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!