Scroll effect does not work jQuery

0

Here is the jQuery code, it's the last thing

Here is the Html

Here is where I want it to move

But fortunately, do not do anything, someone help me please? Thanks: D

    
asked by Sergio A Castañeda Venegas 31.07.2018 в 05:18
source

1 answer

0

This way works pretty well:

JS:

   $(function(){

         $('a[href*=#]').click(function() {

         if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
             && location.hostname == this.hostname) {

                 var $target = $(this.hash);

                 $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');

                 if ($target.length) {

                     var targetOffset = $target.offset().top;

                     $('html,body').animate({scrollTop: targetOffset}, 1000);

                     return false;

                }

           }

       });

HTML:

Link that will take you to the site:

<a id="up" href="#to_up"> UP </a>

And this you put in the place where you want to take you:

<a name="to_up"></a>
    
answered by 31.07.2018 в 05:40