user2078379
user2078379

Reputation: 33

Can't Get jQuery Animated Scroll Working on Chrome

I've been struggling to get an Animated scroll working on this site www.nicbrwn.com/dev but the scrolling only seems to work on Firefox and I need it to work on all platforms.
The jQuery I'm using to 'scroll' is here:

<script>
    $(document).ready(function() {
        $('a[href^="#"]').on('click', function(e) {
            e.preventDefault();    
            var target = this.hash,
                    $target = $(target);    
            $('body').stop().animate({
                'scrollTop': $target.offset().top
            }, 900, 'swing', function() {
                window.location.hash = target;
            });
        });
    });
</script>

All help would be appreciated.

Upvotes: 1

Views: 626

Answers (2)

jmore009
jmore009

Reputation: 12923

You need to remove overflow: auto on the body, html in your css. That's what's stopping it.

Upvotes: 4

Ram
Ram

Reputation: 144689

Select both html and body elements:

$('html, body').stop().animate({});

Upvotes: 1

Related Questions