jQuery替换为淡入淡出/动画 [英] Jquery replacewith fade/animate
本文介绍了jQuery替换为淡入淡出/动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道关于replacewith的问题很多,但似乎没有一个答案适合我的情况.
I know there are loads of questions on replacewith but none seem to have answers that apply to my situation.
html:<div id="foo"></div>
我希望淡出#foo,然后要用淡入的基本上相同的<div id="foo"></div>
替换整个内容(而不仅仅是内容).
I want #foo to be faded out, then I want to replace the whole thing (not just the contents) with essentially the same thing <div id="foo"></div>
which is faded in.
谢谢
推荐答案
$('#foo').fadeOut("slow", function(){
var div = $("<div id='foo'>test2</div>").hide();
$(this).replaceWith(div);
$('#foo').fadeIn("slow");
});
jsfiddle- http://jsfiddle.net/9Dubr/1/
jsfiddle - http://jsfiddle.net/9Dubr/1/
已更新,可以正确淡入
这篇关于jQuery替换为淡入淡出/动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文