Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8550859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:03:38+00:00 2026-06-11T14:03:38+00:00

I have everything working perfectly on my site, but for some reason, I get

  • 0

I have everything working perfectly on my site, but for some reason, I get an error message in console whenever I click a link anywhere on my site. The error has to do with this line of coding here:

jQuery(function($){
  $('.navbar a, .scroll a, .smoothscroll a').bind('click',function(event){
    var $anchor = $(this);

    $('html, body').stop().animate({
        scrollTop: $($anchor.attr('href')).offset().top
    }, 850,'easeInOutExpo');

    event.preventDefault();
  });
});

And the error I am getting is this:

“SCRIPT5007: Unable to get value of the property ‘top’: object is null or undefined
custom.min.js, line 6 character 197”

The exact code it is highlighting is this part of the above code:

$('html, body').stop().animate({
  scrollTop: $($anchor.attr('href')).offset().top
}, 850,'easeInOutExpo')

All I know is that when I remove the above code, my scroll-to links stop working on pages such as these:

http://www.northtownsremodeling.com/things-to-know.php

You can see the popup error happen and stay in the console easily by going to a page with a filter like this:

http://www.northtownsremodeling.com/bathroom/

And clicking one of the filter buttons.

Ultimately, I am trying to make it so my scroll-to setting still works, but not have that error come up anymore. I made this script a long time ago, and I’m really confused as to what could be causing this error when everything is functioning perfectly otherwise?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:03:40+00:00Added an answer on June 11, 2026 at 2:03 pm

    The problem you have is that the code which gives error is for scrolling to predefined div, and you have its id (of target div) in hashtag of url (href attribute of clicked link).

    This is problem when you click “normal” link, because it does not contain hashtag which is id of element existing on page, so $($anchor.attr('href')) gives empty array, because there is no such element which can be selected with i.e. $("http://www.northtownsremodeling.com/alliances.php"), so, in that case offset() is undefined and gives you an error.

    To fix this, replace:

    $('html, body').stop().animate({
        scrollTop: $($anchor.attr('href')).offset().top
    }, 850,'easeInOutExpo');
    

    with:

    // get target div to scroll to
    var target = $($anchor.attr('href'));
    // if target is valid, scroll to
    if(target && target.offset()){
        $('html, body').stop().animate({
            scrollTop: target.offset().top
        }, 850,'easeInOutExpo');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on some form coding in PHP, and I have everything working
I have wrote a custom MultipleChoiceField. I have everything working ok but when I
I have a bunch of self-hosted WCF services. Everything's working fine but I'm look
I'm working on a site for a client, and everything is working perfectly under
I have my navigation menu working perfectly. But when I apply the selected class
I am working on a weather app, and have everything working perfectly ...Except the
I used to have a .js file in /Public/javascripts/jquery1.1js . Everything was working perfectly
I am currently implementing a ListView populated with CheckedTextViews and have everything working just
people. I have slight problem with GD2 text on image. I have everything working
I'm following the Django-CMS introductory tutorial and have got everything working up to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.