jQuery move to anchor location on page load

前端 未结 3 1087
星月不相逢
星月不相逢 2021-01-30 06:22

I have a simple page setup such as:

About us content...
Header content...
3条回答
  •  终归单人心
    2021-01-30 06:55

    Description

    You can do this using jQuery's .scrollTop() and .offset() method

    Check out my sample and this jsFiddle Demonstration

    Sample

    $(function() {
        $(document).scrollTop( $("#header").offset().top );  
    });
    

    More Information

    • jsFiddle Demonstration
    • jQuery.scrollTop()
    • jQuery.offset()

提交回复
热议问题