JavaScript countdown timer code
JavaScript countdown timer code |
you don't need to use any plugin or any third party library..you can create JavaScript countdown timer easily and simply..
just copy the below codes to create JavaScript countdown timer..
countdown.html
<html> <title>JavaScript Countdown Timer Code</title> <head> <script> function cdtd() { var xmas = new Date("December 24, 2018 00:01:00"); var now = new Date(); var timeDiff = xmas.getTime() - now.getTime(); if (timeDiff <= 0) { clearTimeout(timer); document.write("Countdown Complete"); // Run any code needed for countdown completion here } var seconds = Math.floor(timeDiff / 1000); var minutes = Math.floor(seconds / 60); var hours = Math.floor(minutes / 60); var days = Math.floor(hours / 24); hours %= 24; minutes %= 60; seconds %= 60; document.getElementById("day").innerHTML = days; document.getElementById("hour").innerHTML = hours; document.getElementById("min").innerHTML = minutes; document.getElementById("sec").innerHTML = seconds; var timer = setTimeout('cdtd()',1000); } </script> </head> <body> <h2 style="color:green">JavaScript Countdown Timer Code</h2> Days Remaining: <div id="day"></div> Hours Remaining: <div id="hour"></div> Minutes Remaining: <div id="min"></div> Seconds Remaining: <div id="sec"></div> <script>cdtd();</script> </body> </html>
That's it Friends how to create JavaScript countdown timer..
thank for visiting..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.