Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

jquery smooth scrolling

Options
  • 29-04-2009 2: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 Posts: 648 ✭✭✭ChicoMendez


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


Advertisement