在页面加载时触发div [英] Trigger div on pageload
本文介绍了在页面加载时触发div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直试图将页面滚动设置为某个div.请让我知道我该怎么做.以下是我的代码,其中li中的每个选项都移至某个div.我尝试了这个$(#header3").click();在doucument.ready功能中,但是没有用.
I have been trying to set the scroll of my page to a certain div. Kindly let me know how can i do that. Following is my code in which each each option in li moves to certain div . I tried this $("#header3").click(); in doucument.ready function but it didnot work.
请帮助!
<ul id="navigation">
<LI><A class="home selected-lice"href="#header">Home</A></LI>
<LI><A href="#header4">Partners</A></LI>
<LI><A class="about" href="#header5">About Us</A></LI>
<LI><A class="contact" href="#header6">Contact Us</A></LI>
</ul><!-- end of #navigation -->
推荐答案
或者,您可以使用此滚动到 animation :
Alternatively you can use this to scroll to specific element on page load with animation:
$(function(){
$('html, body').animate({ scrollTop: $("#header1").offset().top });
});
这篇关于在页面加载时触发div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文