jQuery 使用附加效果 [英] jQuery using append with effects

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

问题描述

如何使用 .append()show('slow')

等效果

append 产生影响似乎根本不起作用,它给出与正常 show() 相同的结果.没有过渡,没有动画.

如何将一个 div 附加到另一个 div 并对其产生 slideDownshow('slow') 效果?

解决方案

对附加的效果不起作用,因为浏览器显示的内容会在附加 div 后立即更新.因此,结合 Mark B 和 Steerpike 的答案:

在实际附加之前将要附加的 div 设置为隐藏样式.您可以使用内联或外部 CSS 脚本来完成,也可以将 div 创建为

然后您可以将效果链接到您的 append(demo):

$('#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 使用附加效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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