Simple Countdown Timer In Vanilla JavaScript – ysCountDown.js

Category: Date & Time , Javascript | February 27, 2023
Author:yusufsefasezer
Views Total:1,169 views
Official Page:Go to website
Last Update:February 27, 2023
License:MIT

Preview:

Simple Countdown Timer In Vanilla JavaScript – ysCountDown.js

Description:

ysCountDown.js is a simple JavaScript countdown timer plugin for counting time down in DAYS, HOURS, MINUTES, SECONDS.

How to use it:

Insert the minified version of the ysCountDown.js library into the html file.

<script src="dist/yscountdown.min.js"></script>

Create a container element for the countdown timer.

<p id="counter"></p>

Set the end date the countdown timer will count down from.

var endDate = "2018/12/25";

Render the countdown timer inside the container element you created.

var counterElement = document.querySelector("#counter");
var myCountDown = new ysCountDown(endDate, function (remaining, finished) {
    var message = "";
    if (finished) {
      message = "Expired";
    } else {
      message = remaining.totalDays + " d ";
      message += remaining.minutes + " m ";
      message += remaining.seconds + " s ";
    }
    counterElement.textContent = message;
});

Download and checkout the examples folder for more examples.

Changelog:

02/27/2023

  • v1.0.0

You Might Be Interested In:


Leave a Reply