I need to create a countdown that runs daily from 8am to 8pm Monday-Friday and 8am-6pm Saturday and Sunday and then when it's finished, says something like 'We open tomorrow at 8am!'
How can I achieve this?
Website: (you can see where the countdown would be.)
http://www.securemyhome.com/test-pulse3
HTML
<div class="wereOpen"><span class="blue">We'll Call You!</span><br />Only
<span class="countdown">
<!-- COUNTDOWN BANNER -->
7 hours
35 minutes
</span> left!</div>
Here's a few i've tried.
var count=30;
var counter=setInterval(timer, 1000); //1000 will run it every 1 second
function timer()
{
count=count-1;
if (count <= 0)
{
clearInterval(counter);
//counter ended, do something here
return;
}
//Do code for showing the number of seconds here
}
2
function Countdown(options) {
var timer,
instance = this,
seconds = options.seconds || 10,
updateStatus = options.onUpdateStatus || function () {},
counterEnd = options.onCounterEnd || function () {};
function decrementCounter() {
updateStatus(seconds);
if (seconds === 0) {
counterEnd();
instance.stop();
}
seconds--;
}
this.start = function () {
clearInterval(timer);
timer = 0;
seconds = options.seconds;
timer = setInterval(decrementCounter, 1000);
};
this.stop = function () {
clearInterval(timer);
};
}