Skip to content

Instantly share code, notes, and snippets.

@bugoaneo
Created September 9, 2019 14:37
Show Gist options
  • Select an option

  • Save bugoaneo/ceb2098da799236b81d22bdfc32a524c to your computer and use it in GitHub Desktop.

Select an option

Save bugoaneo/ceb2098da799236b81d22bdfc32a524c to your computer and use it in GitHub Desktop.
Cuontdown && packs
if (document.getElementById('countdownTimer')) {
var min = document.getElementById('countdownTimer').getAttribute('data-minutes');
var sec = document.getElementById('countdownTimer').getAttribute('data-seconds');
function countDown() {
sec--;
if (sec == -01) {
sec = 59;
min = min - 1;
} else {
min = min;
}
if (sec <= 9) {
sec = "0" + sec;
}
time = (min <= 9 ? "" + min : min) + ":" + sec;
if (document.getElementById) {
document.getElementById('countdownTimer').innerHTML = time;
}
SD = window.setTimeout("countDown();", 1000);
if (min == '00' && sec == '00') {
sec = "00";
window.clearTimeout(SD);
}
}
window.onload = countDown;
}
function count(packs) {
var pack = document.querySelector('.pack'),
dig = packs;
setInterval(function () {
if (dig !== 0) {
dig--;
} else {
dig = 0;
}
pack.innerHTML = dig;
}, 10000);
}
<p><span class="accent">50%</span> скидка <b>только</b> для наших читателей!
<span id="countdownTimer" class="accent" data-minutes="13" data-seconds="00">13:00 </span>
<a href="http://wttrack.com/click&plase=btn3" class="btn">Заказать сейчас!</a>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment