SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('.tb-countdown').each(function() {
  2.         var date          = $(this).data('countdate');
  3.         var expire_text   = $(this).data('expire-text');
  4.         var countDownDate = new Date(date).getTime();
  5.  
  6.           console.log($(this)); // this $(this) refers to (tb-countdown)
  7.  
  8.         setInterval(function() {
  9.  
  10.           console.log($(this)); // this $(this) refers to var x
  11.  
  12.           // i want here also (tb-countdown refernence)
  13.  
  14.           var now      = new Date().getTime();
  15.           var distance = countDownDate - now;
  16.           var days     = Math.floor(distance / (1000 * 60 * 60 * 24));
  17.           var hours    = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  18.           var minutes  = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  19.           var seconds  = Math.floor((distance % (1000 * 60)) / 1000);
  20.  
  21.           $('.tb-count-days').html(days);
  22.           // $(this).find('#tb-count-hours').html(hours);
  23.           // $(this).find('#tb-count-minutes').html(minutes);
  24.           // $(this).find('#tb-count-seconds').html(seconds);
  25.  
  26.           if (distance < 0) {
  27.             clearInterval(x);
  28.             $('#tb-if-expired').html(expire_text);
  29.           }
  30.         }, 1000);
  31.       });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top