title: Getting javascript - Uncaught TypeError:
body: <p>I am using "numscroller.js" for a counter but Getting 2 javascript Errors - "Uncaught TypeError: Cannot read property 'top' of undefined at HTMLHeadingElement." - 
  <strong>Line no - 40</strong>.</p>
  
  <p>Can anyone help me please with the below code, It's showing the Error is in the line number 40?</p>
  
  <p>Any help would be appreciated, Thank you in Advance.</p>
  
  <p><a href="https://i.stack.imgur.com/NxIBE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NxIBE.jpg" alt="Attached the SCREENSHOT of Errors."></a></p>
  
  <p>Also a working URL - <a href="http://bluecrystaluae.com/counter/counter.html" rel="nofollow noreferrer">http://bluecrystaluae.com/counter/counter.html</a></p>
  
  <pre><code>jQuery.noConflict();
  (function($){
  
      $(window).on("load",function(){
          $(document).scrollzipInit();
          $(document).rollerInit();
      });
      $(window).on("load scroll resize", function(){
          $('.numscroller').scrollzip({
              showFunction    :   function() {
                                      numberRoller($(this).attr('data-slno'));
                                  },
              wholeVisible    :     false,
          });
      });
      $.fn.scrollzipInit=function(){
          $('body').prepend("&lt;div style='position:fixed;top:0px;left:0px;width:0;height:0;' id='scrollzipPoint'&gt;&lt;/div&gt;" );
      };
      $.fn.rollerInit=function(){
          var i=0;
          $('.numscroller').each(function() {
              i++;
             $(this).attr('data-slno',i); 
             $(this).addClass("roller-title-number-"+i);
          });        
      };
      $.fn.scrollzip = function(options){
          var settings = $.extend({
              showFunction    : null,
              hideFunction    : null,
              showShift       : 0,
              wholeVisible    : false,
              hideShift       : 0,
          }, options);
          return this.each(function(i,obj){
              $(this).addClass('scrollzip');
              if ( $.isFunction( settings.showFunction ) ){
                  if(
                      !$(this).hasClass('isShown')&amp;&amp;
                      ($(window).outerHeight()+$('#scrollzipPoint').offset().top-settings.showShift)&gt;($(this).offset().top+((settings.wholeVisible)?$(this).outerHeight():0))&amp;&amp;
                      ($('#scrollzipPoint').offset().top+((settings.wholeVisible)?$(this).outerHeight():0))&lt;($(this).outerHeight()+$(this).offset().top-settings.showShift)
                  ){
                      $(this).addClass('isShown');
                      settings.showFunction.call( this );
                  }
              }
              if ( $.isFunction( settings.hideFunction ) ){
                  if(
                      $(this).hasClass('isShown')&amp;&amp;
                      (($(window).outerHeight()+$('#scrollzipPoint').offset().top-settings.hideShift)&lt;($(this).offset().top+((settings.wholeVisible)?$(this).outerHeight():0))||
                      ($('#scrollzipPoint').offset().top+((settings.wholeVisible)?$(this).outerHeight():0))&gt;($(this).outerHeight()+$(this).offset().top-settings.hideShift))
                  ){
                      $(this).removeClass('isShown');
                      settings.hideFunction.call( this );
                  }
              }
              return this;
          });
      };
      function numberRoller(slno){
              var min=$('.roller-title-number-'+slno).attr('data-min');
              var max=$('.roller-title-number-'+slno).attr('data-max');
              var timediff=$('.roller-title-number-'+slno).attr('data-delay');
              var increment=$('.roller-title-number-'+slno).attr('data-increment');
              var numdiff=max-min;
              var timeout=(timediff*1000)/numdiff;
              //if(numinc&lt;10){
                  //increment=Math.floor((timediff*1000)/10);
              //}//alert(increment);
              numberRoll(slno,min,max,increment,timeout);
  
      }
      function numberRoll(slno,min,max,increment,timeout){//alert(slno+"="+min+"="+max+"="+increment+"="+timeout);
          if(min&lt;=max){
              $('.roller-title-number-'+slno).html(min);
              min=parseInt(min)+parseInt(increment);
              setTimeout(function(){numberRoll(eval(slno),eval(min),eval(max),eval(increment),eval(timeout))},timeout);
          }else{
              $('.roller-title-number-'+slno).html(max);
          }
      }
  })(jQuery);
  </code></pre>