jQuery:slideUp()delay()然后slideDown;不工作 [英] jQuery: slideUp() delay() then slideDown; not working
问题描述
我正在尝试实现一个非常简单的页脚通知元素,以使其向上滑动一会儿,然后向下滑动.我正在使用:
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');
});
但是,当您单击按钮时,它会延迟1500毫秒,然后向上滑动,而永远不会向下滑动.
However, when you click the button, it delays for the 1500 ms then slides up and never slides down.
推荐答案
您真正想要的是这个
$('#message-box').slideDown('slow').delay(1500).slideUp('slow');
您可以在此处进行测试.尽管从您的布局来看似乎有些倒退,但 .slideDown()
用于显示一个元素,并且 .slideUp()
用于隐藏一个元素...即使给出了CSS,它实际上还是在上升显示时.
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.
此外,在编辑小提琴时,您不需要<html>
和<body>
标记,这些标记已经包含在内.html框架中的所有内容都将放入<body>
内.
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>
.
这篇关于jQuery:slideUp()delay()然后slideDown;不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!