Created
January 21, 2017 00:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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..."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://davidwells.io/run-javascript-function-on-a-specific-day/