jQuery 面板在页面加载时向下滑动然后向上滑动
这应该很简单,但我就是无法让它正常工作。
以下代码应该能够执行以下操作。页面加载完成后,页面顶部的 div (div#panel) 应向下滚动到视图中。延迟几秒钟后,div 应该向上滚动离开视图。当用户单击触发器时,div 还应该能够上下切换/滑动。
预先感谢您的意见/建议。
$(document).ready(function() {
$("div#panel").slideDown("slow");
setTimeout(function(){
$("div#panel").slideUp("slow");
}, 5000);
});
$(document).ready(function() {
// Expand Panel
$("#open").click(function(){
$("div#panel").slideDown("slow");
});
// Collapse Panel
$("#close").click(function(){
$("div#panel").slideUp("slow");
});
});
This is suppose to be very simple, however I just can't get it to work as it should.
The following code should be able to do the following. As soon as page completes loading, a div (div#panel) at the top of the page should scroll down into view. After a few seconds delay the div should scroll back up out off view. The div should also be able to toggle/slide up and down as user clicks on a trigger.
Thanks in advance for advice/suggestions.
$(document).ready(function() {
$("div#panel").slideDown("slow");
setTimeout(function(){
$("div#panel").slideUp("slow");
}, 5000);
});
$(document).ready(function() {
// Expand Panel
$("#open").click(function(){
$("div#panel").slideDown("slow");
});
// Collapse Panel
$("#close").click(function(){
$("div#panel").slideUp("slow");
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须先
hide()
面板,这样它才能滑入视图。演示:http://jsfiddle.net/X9Vn4/6/
You have to
hide()
the panel first, so it can slide into view.Demo: http://jsfiddle.net/X9Vn4/6/
你也可以试试这个。当slideDown执行完成时加载slideUp。
You could also try this. Load slideUp when slideDown completes execution.