Created
August 16, 2013 12:55
-
-
Save abbotto/6249642 to your computer and use it in GitHub Desktop.
JavaScript: A function that uses images to perform a 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
<style type="text/css"> | |
.countDown { | |
font-family:"Helvetica Neue",Helvetica,Calibri,"Liberation Sans",Arial,sans-serif; | |
font-weight:300; | |
letter-spacing:0.5px; | |
text-align:center; | |
} | |
</style> | |
<script type="text/javascript"> | |
currentDate = new Date(); | |
zeroDay = new Date("January 1, 2013"); // <===|INSERT_DATE_HERE | |
msPerDay = 864E5; | |
time = (zeroDay.getTime() - currentDate.getTime()); | |
days= time / msPerDay; | |
dayCount = Math.floor(days); | |
image = parseInt(dayCount) + 2; | |
countDown ="<div id='countDown' class='countDown'>It's coming. Are you ready?<br>"+dayCount+" days until "+zeroDay+".</div>"; | |
if (dayCount > 30){document.write(countDown);} | |
else if (dayCount <= 30){document.write("<img id='countDown' class='countDown' src='"+image+".jpg' alt='It's coming.'/>");} | |
else {document.write("<img id='countDown' class='countDown' src='1.jpg' alt=''It's coming.'/>");} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment