jQuery的使用效果与追加 [英] jQuery using append with effects

查看:146
本文介绍了jQuery的使用效果与追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 .append()的效果显示('慢')

有关于追加似乎并没有在所有的工作,并给予同样的结果为正常显示()。没有过渡,没有动画。

Having effects on append doesn't seem to work at all, and it give the same result as normal show(). No transitions, no animations.

我怎么可以在一个分区追加到另一个,并有一个了slideDown 显示('慢')效果它?

How can I append one div to another, and have a slideDown or show('slow') effect on it?

推荐答案

有上追加效果将无法工作,因为内容的浏览器显示是尽快DIV附加更新。所以,马克B的和Steerpike的回答结合起来:

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:

风格,你要追加为隐藏在你真正追加的div。您可以通过内嵌或外置CSS脚本做到这一点,或者只是创建DIV为

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');

或(演示):

var $new = $('#new_div');
$('#original_div').append($new);
$new.show('slow');

这篇关于jQuery的使用效果与追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆