这是我的第一篇文章在这里。我搜查了很多,但我还没有发现任何关于此。javascript:jQuery的replaceWith()不尊重延迟()
我无法按预期工作这个脚本(它在运行时错误):
(function ($) {
$("div#replace").click(function() {
$(this).fadeOut("200").delay("200").replaceWith("<div id='replace'>new content</div>").delay("200").fadeIn("200");
});
})(jQuery);
我是从DIV#希望这种替换:
淡出 - >更改内容 - >淡入
相反,我得到了这种行为:
变化的内容 - >淡出 - >淡入
[编辑]谢谢你们,我有一个解决方案。我在这里发布它:
我使用Spokey的方法,并且从replaceWith()切换到了html(),它使fadeIn动画正常工作。
$("div#replace").click(function() {
$(this).fadeOut("200", function() {
$(this).html("new content").fadeIn("200");
});
});
谢谢!对不起我的英文不好:)
尝试用'的.html的()''而不是replaceWith()' – 2014-10-01 09:42:42
这就是为什么你必须'callbacks'使用。 – melancia 2014-10-01 09:42:59