Jump to content
Forgot your email address? ×
×
×
  • Create New...
  • 0

Scroll To Top


BerkayAta

Question

  • Answers 8
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

8 answers to this question

Recommended Posts

  • 0
  • Moon

jQuery( document ).ready(function() {
    jQuery('.scroll-smooth').click(function (e) {
        e.preventDefault();
        var status_id = $(this).attr('href').split('#');
        var element = jQuery("#" + status_id[1]);
        if(element.length > 0) {
            scroll = element.offset().top - 40;
            jQuery("html, body").animate({
                scrollTop: scroll
            }, 1000);
        }
    });
});
Now just attach the class "scroll-smooth" your button an in the href tag you put your id you want to scroll to (if you want to go top give the body the id scrolltop and let the link look like that:

<a href="#scrolltop">LINK</a>

 

You can watch a demo here:

http://pollux2.com/stats

 

At the bottom you find "Nach oben" (german for to top) click on that and it will smothly scroll to top

Link to comment
  • 0

jQuery( document ).ready(function() {
    jQuery('.scroll-smooth').click(function (e) {
        e.preventDefault();
        var status_id = $(this).attr('href').split('#');
        var element = jQuery("#" + status_id[1]);
        if(element.length > 0) {
            scroll = element.offset().top - 40;
            jQuery("html, body").animate({
                scrollTop: scroll
            }, 1000);
        }
    });
});
Now just attach the class "scroll-smooth" your button an in the href tag you put your id you want to scroll to (if you want to go top give the body the id scrolltop and let the link look like that:

<a href="#scrolltop">LINK</a>

 

You can watch a demo here:

http://pollux2.com/stats

 

At the bottom you find "Nach oben" (german for to top) click on that and it will smothly scroll to top

 

 

Thanks but I don't want this :)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


  • Read our Rules
  • Activity

    1. 7

      PHOENIX2 !OLDSCHOOL SERVER, PAYTOWIN REMOVED!

    2. 0

      special_item_group and chest apprentice

    3. 2

      Alternative Alternative Zodiac Suit - Ninja M

    4. 0

      character details negative bonus

    5. 0

      Questlib mysql_query function problem

  • Recently Browsing

    • No registered users viewing this page.

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.