Need help adding Javascript

Posted in: Newspaper
Post count: 32

I’m trying to add an animation effect when clicking an anchor link, so that the page does not jump to that section. I’m using the following under Custom Code > Javascript in the theme panel.


src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js";

// Bind all a href clicks to this function
        $(document).on('click', 'a', function(event){

            // Prevent default events
            event.preventDefault();

            // Animate the body (html page) to scroll to the referring element 
            $('html, body').animate({
                scrollTop: $( $.attr(this, 'href') ).offset().top
            }, 1000);

        });

I followed instructions to not include the script tags but it does not seem to be working. Here is the page I’m trying to get it to function on: https://mp.adcreview.com/privacy-statement/ – the links to anchors are in the right rail.

  • This topic was modified 6 years by smehr1.
Post count: 35449

Hi,

Did you try to set the code like this -> http://prntscr.com/pnwg8a and this was not working, if is so, then, please set the code like this -> http://prntscr.com/pnwh5p -> http://prntscr.com/pnwhce

Hope this will help you!
Thank you!

Post count: 32

Thank you Calin!

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.