javascript countdown 1 minute
<script>
function startTimer(duration, display) {
var timer = duration, minutes, seconds;
setInterval(function () {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);
// minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = seconds;
if (--timer < 0) {
timer = duration;
}
}, 1000);
}
window.onload = function () {
var fiveMinutes = 60 * 5,
display = document.querySelector('#time');
startTimer(fiveMinutes, display);
};
</script>
<span id="time"></span>
Also in JavaScript:
- enable version 12 node glitch
- singly even magic square creation algorithm
- get value from textbox in vanilla javascript
- javascript determine if string is valid url
- make string json object vue
- javascript detect touch
- javascript float to int
- Javascript get text input value
- how to cast to javascript executor
- in out time of nodes
- creating a nested loop of a chessboard in javascript
- add table header dynamically in jquery
- get selected text js
- javascript sleep settimeout
- function takes object name and property name and new value
- nodemon.json env
- javascript remove from array by index
- regex for lowercase letters js
- c# beautify json string
- javascript loop object
- dotenv
- import json file javascript
- recursive permutation
- foreach jquery