"JavaScript CountDown Timer" is a handy web-based tool that enables users to set countdowns for various events. It's built using JavaScript, offering a sleek and intuitive interface for precise time tracking and anticipation of important deadlines.
A simple and customizable countdown timer implemented in JavaScript.
- Set a specific countdown time in hours, minutes, and seconds.
- Display the remaining time in a user-friendly format.
- Start, pause, and reset the countdown timer.
- Customizable visual styling using CSS.
- Trigger a callback function when the countdown reaches zero.
Check out the live demo of the countdown timer: Live Demo
-
Clone the repository:
git clone https://github.com/your-username/javascript-countdown-timer.git
-
Include the
countdown-timer.js
file in your HTML:<script src="path/to/countdown-timer.js"></script>
-
Add the necessary HTML markup to your page:
<div id="countdown"></div>
-
Create a new instance of the CountdownTimer:
const countdownTimer = new CountdownTimer('countdown', { hours: 1, minutes: 30, seconds: 0, onTick: handleTick, onComplete: handleComplete });
-
Customize the countdown timer options as needed:
hours
(optional): Number of hours for the countdown (default: 0).minutes
(optional): Number of minutes for the countdown (default: 0).seconds
(optional): Number of seconds for the countdown (default: 0).onTick
(optional): Callback function called on every tick of the timer.onComplete
(optional): Callback function called when the timer reaches zero.
-
Start the countdown timer:
countdownTimer.start();
The countdown timer can be styled using CSS. The main container has the countdown-timer
class, and each unit (hours, minutes, seconds) has its own class (countdown-timer__hours
, countdown-timer__minutes
, countdown-timer__seconds
).
.countdown-timer {
/* Your styles here */
}
.countdown-timer__hours {
/* Your styles here */
}
.countdown-timer__minutes {
/* Your styles here */
}
.countdown-timer__seconds {
/* Your styles here */
}
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.