问题描述
如何将 .append()
与 show('slow')
对append
产生影响似乎根本不起作用,它给出与正常show()
相同的结果.没有过渡,没有动画.
如何将一个 div 附加到另一个 div 并对其产生 slideDown
或 show('slow')
效果?
对附加的效果不起作用,因为浏览器显示的内容会在附加 div 后立即更新.因此,结合 Mark B 和 Steerpike 的答案:
在实际附加之前,将要附加的 div 设置为隐藏样式.您可以使用内联或外部 CSS 脚本来完成,也可以将 div 创建为
... </div>
然后您可以将效果链接到您的附加内容(演示):
$('#new_div').appendTo('#original_div').show('slow');
或者(演示):
var $new = $('#new_div');$('#original_div').append($new);$new.show('慢');
How can I use .append()
with effects like show('slow')
Having effects on append
doesn't seem to work at all, and it give the same result as normal show()
. No transitions, no animations.
How can I append one div to another, and have a slideDown
or show('slow')
effect on it?
Having effects on append won't work because the content the browser displays is updated as soon as the div is appended. So, to combine Mark B's and Steerpike's answers:
Style the div you're appending as hidden before you actually append it. You can do it with inline or external CSS script, or just create the div as
<div id="new_div" style="display: none;"> ... </div>
Then you can chain effects to your append (demo):
$('#new_div').appendTo('#original_div').show('slow');
Or (demo):
var $new = $('#new_div');
$('#original_div').append($new);
$new.show('slow');
这篇关于jQuery 使用附加效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!