javascript - 使用淡入淡出和追加

标签 javascript jquery fade

我正在将 JSON 数据加载到我的页面并使用 appendTo() 但我试图淡入我的结果,有什么想法吗?

$("#posts").fadeIn();
$(content).appendTo("#posts");

我在文档中看到 appendappendTo 之间存在差异。

我也试过这个:

$("#posts").append(content).fadeIn();

我明白了,上面的方法成功了!

但我得到 "undefined" 作为我的 JSON 值之一。

最佳答案

如果您在追加之前隐藏内容并将 fadeIn 方法链接到它,您应该会得到您正在寻找的效果。

// Create the DOM elements
$(content)
// Sets the style of the elements to "display:none"
    .hide()
// Appends the hidden elements to the "posts" element
    .appendTo('#posts')
// Fades the new content into view
    .fadeIn();

关于javascript - 使用淡入淡出和追加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/327682/

相关文章:

javascript - 无法迭代 React Native 中的本地资源

javascript - Durandal.js - 组合与小部件

jquery - Galleria & LightBox IE7 & IE8 css 问题

c# - HTMLAgilityPack 从屏幕读取值

javascript - ExtJS 树面板无法正确显示元素

javascript - 回调窗口对象初始化(在页面中动态包含 iframe)

jquery - .serialize contentEditable div?

javascript - 为 div 类添加淡入淡出效果

javascript - 为什么我不能在这里使用多个ID?

android - 如何在 Android 中逐个字母淡入 TextView