javascript - Cannot read property 'top' of undefined error only on live server -


the function below works without errors on local server on live server 'cannot read property 'top' of undefined' error , link wont work @ all. causing that? how can fix it?

    <a class="herojumplink" href="#homestatement"></a>      <section class="fullcopy homestatement" id="homestatement"></section>             $('.herojumplink').on('click',function (e) {              e.preventdefault();             var target = this.hash;              $('html, body').stop().animate({                  'scrolltop': $(target).offset().top -70 + 'px'              }, 300, 'linear');          });  

this should work if target exists.

$('.herojumplink').on('click',function (e) { //e.preventdefault(); var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) {     $('html,body').animate({             scrolltop: target.offset().top - 70 //offset         }, 300);     return false; } 

});


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -