Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

jquery smooth scrolling

  • 29-04-2009 02:42PM
    #1
    Closed Accounts Posts: 184 ✭✭


    I'm trying to implement a script to scroll smoothly to inline links on my site, I'm having no success with this. Anyone shed some light on this?
    $(document).ready(function(){
    $('a[href*=#]:not([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;
    }
    }
    });
    });
    


Comments

  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭ChicoMendez


    theres an easy to use plugin that does this - why dont u use that ?


Advertisement