我正在将 JSON 数据加载到我的页面并使用 appendTo()
但我试图淡入我的结果,有什么想法吗?
$("#posts").fadeIn();
$(content).appendTo("#posts");
我在文档中看到 append
和 appendTo
之间存在差异。
我也试过这个:
$("#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/