• How To?
  • Tips ‘n Tricks
  • WordPress
  • Snippets
  • Software
    • Browsers
    • Downloads
  • Web
  • Tools
    • Character Counter
    • chmod Calculator
    • Entities Encoder
    • Live HTML Editor
    • My IP
  • Contact
Twitter Facebook Google+ RSS
You are here: SumTips » Snippets » JavaScript Snippets » Smooth Scroll to Page Top without an Anchor

Smooth Scroll to Page Top without an Anchor

Posted on October 11, 2011 by Renji | Short URL: http://sumtips.com/?p=5211

This little jQuery snippet adds a smooth scroll-to-top effect on a page.  Unlike some other methods, this doesn’t need an anchor for the scroll effect to work on a page.

You can change the scroll speed and “scroll up to” position in this script.

$(document).ready(function(){

    $(".top").click(function(e){

        e.preventDefault();

        $("body,html").animate({
            scrollTop: 0 // Top position
        },800); // Scroll speed

    });

});

Demo


Tweet

Related posts:

  • Automatically Scroll Long Pages in Google Chrome with TelePrompter
  • Google Launches Online Version of Page Speed
  • Google's Page Speed Extension Now Available For Google Chrome
  • Web Page Prerendering – Super-fast Page Loads on Chrome
  • Facebook Allows Page Name Change & Tests New Page Admin Interface
Categories: JavaScript Snippets
Show-Hide Password in a Field

  • Get Updates via Email

  • Recent Posts

    • CMS2CMS: Migrate Site from Drupal or Joomla to WordPress
    • WordPress: Add Preview Button in Distraction Free Writing
    • How to Activate or Deactivate Individual Jetpack Modules
    • Windows 8: Auto Update Defender with Windows Update Disabled
    • Automatically Start and Close Programs at Specific Time
    • How to Copy Code from Notepad++ with Syntax Highlighting
  • Random Posts

    • Foursquare Downward Facing Dog Badge
    • Associate File Extensions to Portable Applications
    • Strip Metadata off Images
    • Add, Delete and Edit Custom Fields in WordPress
    • Extract Images from PDF Files or Convert PDF Pages to Images
    • Add Support for Theme Customizer in WordPress 3.4 Themes
  • Categories

    • Blogging
    • Games
    • Google
    • How To?
    • Linux
    • Microsoft
      • Windows
    • Miscellaneous
    • Phone
    • Snippets
      • AutoHotkey Snippets
      • CSS Snippets
      • htaccess Snippets
      • JavaScript Snippets
      • PowerShell Snippets
      • WordPress Snippets
    • Social
    • Software
      • Browsers
    • Tips 'n Tricks
    • Wallpapers
    • Web
© SumTips. Contact | Sitemap | Privacy Policy