jQuery: slideUp() delay() then slideDown; not working

自古美人都是妖i 提交于 2019-12-01 00:21:13

问题


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/


回答1:


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>.



来源:https://stackoverflow.com/questions/3833076/jquery-slideup-delay-then-slidedown-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!