Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14655 reviews 1734 hosting providers

Questions & Answers

scroll page down after anchor?

Mar 11, 2013 by deepa1
I have recently added a fixed menu at the top of my page. But I have an issue when any anchor link is clicked the page scrolls to the anchor which is now covered with the newly placed top menu. How can I catch the anchor event using javascript?

2 Answers

0 votes
Mar 11, 2013 by TopNet
0 votes
Mar 12, 2013 by WebGuru
You have to calculate the offset of the element so you can scroll to the element’s offset  position:
    // height of the navigation bar
    var height= $("#nav").outerHeight();
    // referenced dom-element position
    var pos = $($(this).attr("href")).position().top;
    // scroll to your element
    // override default
    return false;