WP mobile jquery scrolltodiv from menu

I´m working on a responsive wordpress site where on small screens(mobile) I want to scroll to #content when a menu-item is clicked as the menu takes up most of the screenspace. I´ve tried these script but didn´t work.

1

Read More
$("#access a").click(function() {
$("#goto").animate({scrollTop: $("#goto").offset().top});
});

2

$("html, body").animate({ scrollTop: $('#goto').offset().top }, 1000);

Is there a simple solution for this?

Related posts

Leave a Reply

1 comment

  1. I answered a similar question a while back here, which worked great.

    Based on that answer, try this:

    $(function() {
    var scrollElement = '#content';
    var destination = $(scrollElement).offset().top;
    $("#access a").click(function() {
        $(scrollElement).offset().top;
        $("html:not(:animated),body:not(:animated)").animate({
            scrollTop: destination-75 }, 800 );
        });
    });​
    

    Note, the number 75 can be tweaked to get the page to scroll exactly where you want it to.