Skip to content Skip to sidebar Skip to footer

Jquery ScrollTo Issue

I am using Jquery ScrollTo so that when I click a question at the top of the page it will scroll to the question and answer further down the screen. This function works ok ( To a

Solution 1:

Your site is correctly scrolling. Problem is that Your navbar is stacked to top and covers content. I write it a lil bit different than You but it works:

$(document).ready(function () {
    var navHeight = $('.navbar').height(); //get the navbar height

    $(".top_links > li > a").click(function (e) {
        $(".faq > li").removeClass('highlight');

        var str = $(this).attr("href");
        str = "a[name='" + str.substring(1) + "']";
        $(str).parent().addClass('highlight');
        e.preventDefault(); // prevent adding something to url
        var offset = $('.highlight').offset(); //get highlight position from top of page

        $('html, body').scrollTop(offset.top-navHeight); // scroll to correct position
    });

    $('.top').find('a').on('click', function(e){
       $('html, body').scrollTop(0);
       e.preventDefault();
    });
});​

Post a Comment for "Jquery ScrollTo Issue"