Week 10 - Int219
Week 10 - Int219
week:10
Roll no:41
INT:219
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Countdown Timer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-green-700 flex justify-center items-center h-screen">
<div class="bg-white rounded-lg shadow-lg p-6 w-80 text-center">
<h1 class="text-xl font-bold text-green-700 mb-4">Countdown Timer</h1>
<input type="number" id="timeInput" placeholder="Enter Seconds"
class="w-full p-2 border border-green-800 rounded-md text-center text-
lg focus:outline-green-900">
<button onclick="startCountdown()"
class="w-full bg-green-800 text-white py-2 mt-3 rounded-md
hover:bg-green-700 transition shadow-lg shadow-gray-500
">
Start Countdown
</button>
<div id="timer" class="mt-4 p-2 text-2xl font-bold text-gray-
700">00:00</div>
</div>
<script>
let countdown;
function startCountdown() {
clearInterval(countdown);
const input = document.getElementById("timeInput").value;
let timeLeft = parseInt(input, 10);
function updateTimerDisplay() {
let minutes = Math.floor(timeLeft / 60);
let seconds = timeLeft % 60;
document.getElementById("timer").innerText =
String(minutes).padStart(2, "0") + ":" + String(seconds).padStart(2,
"0");
}
updateTimerDisplay();