Skip to content

Instantly share code, notes, and snippets.

@christophherr
Created January 21, 2017 00:59
Show Gist options
  • Save christophherr/287c179a1c6152a349e9cb54550e963a to your computer and use it in GitHub Desktop.
Save christophherr/287c179a1c6152a349e9cb54550e963a to your computer and use it in GitHub Desktop.
Countdown timer with jQuery.countdown and JS to change the HTML aftter the end of the countdown
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="webinar-timer">
<span class="webinar-countdown"></span>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script>
</body>
</html>
jQuery(function( $ ){
$(".webinar-countdown").countdown("2017/01/20 18:41:20", function(event) {
$(this).text(event.strftime('%D days %H:%M:%S'));})
.on('finish.countdown', function(event) {
$(this).html('The webinar is over!').parent().addClass('disabled');
$(".webinar-timer").html('The webinar is over!').addClass('disabled');
});
});
var webinarDate = {
month: 0,
date: 20,
hour: 18,
minute: 41
}
function isItWebinarDay() {
var now = new Date();
return (now.getMonth() == webinarDate.month && now.getDate() == webinarDate.date && now.getHours() == webinarDate.hour && now.getMinutes() == webinarDate.minute );
}
if(isItWebinarDay()){
console.log("HURRAY!");
} else {
console.log("PATIENCE...");
}
@christophherr
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment