页面加载后如何使用 jQuery 滑动
我在尝试向下滑动更多信息 div 时遇到计时问题。我想要的功能是,一旦页面已经呈现,div就会从顶部滑落。我的问题是,如果我使用 $(document).ready().. 动画不会明显发生。
这是我的代码:
$(document).ready(function() {
$(".MoreInfo").slideDown('slow');
});
例如,如果我将它绑定到其他一些元素的点击上,它就会工作得很漂亮。但我不知道如何让它在页面加载后明显地向下滑动。 谢谢!
I am having a timing issue when attempting to slide down my more info div. My desired functionality is that the div slidesdown from the top once the page has already been rendered. My problem is if I use $(document).ready().. the animation does not visibly occur.
Here is my code:
$(document).ready(function() {
$(".MoreInfo").slideDown('slow');
});
If I strap it to some other element's click for example, it works beautifully. But I am not sure how to make it visibly slide down once the page has loaded.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
进行混合和匹配,
我尝试使用: and
但没有任何运气。我最终使用了
,这似乎有效。我认为这与已经显示的元素有关。
I tried mixing and matching using:
and
but did not have any luck. I ended up using
and that seemd to work. I think it had to do with the element already being displayed more than anything else.
您可能想尝试使用
而不是
因为当 $(document).ready 触发时您尝试操作的某些元素可能未完全加载。
You might want to try using
instead of
as some of the elements you are trying to manipulate might not be completely loaded when $(document).ready fires.
也许可以尝试使用 body onload 来代替
...只要 DOM 可以操作,document.ready 就会发生,不一定一旦页面显示 - 它可能在页面显示之前发生。您也可以尝试将其放在
setTimeout
调用中以留出一点额外的时间Perhaps try body onload instead
...document.ready occurs as soon as the DOM can be manipulated, not necessarily once the page is displayed - it could be well before the page is displayed. You could also try putting this on a
setTimeout
call to allow a little extra time