简体   繁体   English

使用 jquery 在特定(位置)div 加载页面

[英]Load a page at a specific (location) div using jquery

I have a question relating to loading a page (initial load, not anchors) to a certain div that is not at the top of the page.我有一个关于将页面(初始加载,而不是锚点)加载到不在页面顶部的某个 div 的问题。

For example, I have div#one at the top of the page, and it is full width, and full height of my screen.例如,我在页面顶部有div#one ,它是我屏幕的全宽和全高。 Underneath that, I have another div, div#two , that is the same size, but hidden beneath the first one.在它下面,我有另一个 div, div#two ,它的大小相同,但隐藏在第一个下面。

Now, I want the page to load div#two right off the bat, and I can scroll back up if I want.现在,我希望页面立即加载 div#two,如果需要,我可以向上滚动。 What I have works, but it scrolls down in a second after load:我有什么工作,但它在加载后一秒钟向下滚动:

  $(document).ready(function () {
        // Handler for .ready() called.
        $('html, body').animate({
            scrollTop: $('#two').offset().top
        }, 'fast');
    });

What I need is to eliminate the animate in this equation.我需要的是消除这个方程中的动画。 Can anyone help me?谁能帮我?

Thanks!谢谢!

Just use document.location.href="#two";只需使用document.location.href="#two"; . . :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM