Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Incrementing Javascript



Site URL: https://www.brianspoem.com


I currently have a script running in the sidebar that counts the number of poems. It works, but the only problem is that I have to increment it manually. I asked a programmer friend if he could help me with a script that would count the number of poems from a starting date so that I would not have to manually edit the script each day. Below is the code he sent me. Unfortunately, I can't get this script to run and he is not able to help me. This script is very much like the script currently running, so I'm not sure what the problem is. Any insight or suggestions are greatly appreciated.

🙂 Brian

===================SCRIPT BELOW===================

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
var a = 0;
$(window).scroll(function() {

  var oTop = $('#counter').offset().top - window.innerHeight;
  if (a == 0 && $(window).scrollTop() > oTop) {
    $('.counter-value').each(function() {
      var $this = $(this),
        startDate = getDaysSinceStartDate($this.attr('data-startdate'));
        countNum: $this.text()
          countNum: startDate
          duration: 2000,
          easing: 'swing',
          step: function() {
          complete: function() {
    a = 1;
function getDaysSinceStartDate(startDate) {
   var today = new Date().getTime() / 1000;
   startDate = Date.parse(startDate) / 1000;
   return Math.floor((today - startDate) / 60 / 60 / 24);

<div id="counter">
<div class="sqs-col sqs-col-4 counter-value" data-startdate="07/22/2016" data-desc="Poems

Edited by Digital-Alphabet
Link to post
  • Answers 0
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...