jQuery(function($){ "use strict"; jQuery(document).ready(function($) { /* Timer */ var target = $('#counter').data('date'); var finished = false, availiableExamples = { set15daysFromNow: 15 * 24 * 60 * 60 * 1000, set5minFromNow: 5 * 60 * 1000, set1minFromNow: 1 * 60 * 1000 }; function callback(event) { var $this = $(this); switch (event.type) { case "seconds": case "minutes": case "hours": case "days": case "weeks": case "daysLeft": $this.find('div span#' + event.type).html(event.value); if (finished) { $this.fadeTo(0, 1); finished = false; // David Leonardi 4th January 2018 : if counter is zero, show "Now!" document.getElementById("counter").style.display = "block"; document.getElementById("counterNow").style.display = "none"; } break; case "finished": // David Leonardi 4th January 2018 : if counter is zero, show "Now!" $this.fadeTo('slow', .5); document.getElementById("counter").style.display = "none"; document.getElementById("counterNow").style.display = "block"; finished = true; break; } } $('#counter').countdown(target, callback); }); });