jQuery:slideUp()延迟()然后slideDown;不工作

发布于 2024-09-25 14:03:49 字数 332 浏览 3 评论 0原文

我正在尝试实现一个非常简单的页脚通知元素,向上滑动一会儿,然后向下滑动。我正在使用:

$('button').click( function () {
    $('#message-box').slideUp('slow').delay(1500).slideDown('slow');
});

但是,当您单击按钮时,它会延迟 1500 毫秒,然后向上滑动,并且永远不会向下滑动。

http://jsfiddle.net/jrMH3/17/

I'm trying to implement a very simple footer notification element to slide up for a moment, then slide back down. I'm using:

$('button').click( function () {
    $('#message-box').slideUp('slow').delay(1500).slideDown('slow');
});

However, when you click the button, it delays for the 1500 ms then slides up and never slides down.

http://jsfiddle.net/jrMH3/17/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

穿越时光隧道 2024-10-02 14:03:49

您真正想要的是:

 $('#message-box').slideDown('slow').delay(1500).slideUp('slow');

您可以在此处测试。虽然考虑到您的布局,它看起来有点倒退,但 .slideDown() 用于显示 一个元素,.slideUp() 用于隐藏 一个元素...即使给定你的 CSS,它在显示时实际上会上升。

另外,编辑小提琴时不需要 标签,这些标签已经包含在... html 框架将进入 内部。

What you actually want is this:

 $('#message-box').slideDown('slow').delay(1500).slideUp('slow');

You can test it here. Though it seems a bit backwards given your layout, .slideDown() is for showing an element, and .slideUp() is for hiding an element...even though given your CSS it's actually going up when shown.

Also as an aside, you don't need <html> and <body> tags when editing the fiddle, these are already included...any content in the html frame will go inside the <body>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文