Q: JQuery smooth Scroll error I'm having an issue with my smooth scroll script, which worked on another site I did, but its throwing up errors on my new site. The code is exactly the same.


<html>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script>
        $(document).ready(function (){
            $("#click").click(function (){
                $('html, body').animate({
                    scrollTop: $("#div1").offset().top
                }, 2000);
            });
        });
    </script>
    <div id="div1" style="height: 1000px; width 100px">
        Test
    </div>
    <br/>
    <div id="div2" style="height: 1000px; width 100px">
        Test 2
    </div>
    <button id="click">Click me</button>
</html>


This is the error I'm getting in Chrome and Opera:
Uncaught TypeError: Cannot read property 'top' of undefined
at HTMLDivElement.<anonymous> ((index):31)
at HTMLDivElement.dispatch (jquery.min.js:3)
at HTMLDivElement.r.handle (jquery.min.js:3)

