Developer-first advanced web creation
LIGHT / DARK
Supported technologies
Supported
technologies
Supported technologies
Supported
technologies
Code at AI-speed
1 $w.onReady(function () {
2 const countdownElement = $w('#countdown');
3 let remainingSeconds = 60;
4
5 function updateCountdown() {
6 countdownElement.text = formatTime(remainingSeconds);
7 remainingSeconds--;
8
9 if (remainingSeconds >= 0) {
10 setTimeout(updateCountdown, 1000);
11 } else {
12 countdownElement.text = "Time's up!";
13 }
14 }
15
16 function formatTime(seconds) {
17 const minutes = Math.floor(seconds / 60);
18 const formattedMinutes = String(minutes).padStart(2, '0');
19 const formattedSeconds = String(seconds % 60).padStart(2, '0');
20 return `${formattedMinutes}:${formattedSeconds}`;
21 }
22
23 updateCountdown();
24 });
$w.onReady(function () {
const countdownElement = $w('#countdown');
let remainingSeconds = 60;
function updateCountdown() {
countdownElement.text = formatTime(remainingSeconds);
remainingSeconds--;
if (remainingSeconds >= 0) {
setTimeout(updateCountdown, 1000);
} else {
countdownElement.text = "Time's up!";
}
}
function formatTime(seconds) {
const minutes = Math.floor(seconds / 60);
const formattedMinutes = String(minutes).padStart(2, '0');
const formattedSeconds = String(seconds % 60).padStart(2, '0');
return `${formattedMinutes}:${formattedSeconds}`;
}
updateCountdown();
});