I am loading JSON data to my page and using appendTo() but I am trying to fade in my results, any ideas?

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

我看到文件上有appendappendTo的区别.

I tried this as well:

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

I got it, the above did the trick!

But I get "undefined" as one of my JSON values.

推荐答案

如果在追加内容之前将其隐藏,并将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();

Jquery相关问答推荐

如何向父元素添加类?

是否可以从不可见的 DataTables 列访问数据?

使用带有 Ajax GET URL 的数组在每次单击按钮时一次单步执行一个

jQuery 上传进度和 AJAX 文件上传

在 for 循环中分配点击处理程序

在页面上放置文件时如何设置文件输入值?

在 jQuery UI Datepicker 中禁用future 日期

如何使用 jQuery UI Resizable 仅水平或垂直调整大小?

当ID包含方括号时按ID查找DOM元素?

jQuery切换文本?

iframe 仅显示页面的特定部分

聚焦 时防止 iphone 默认键盘

jquery-ui datepicker更改z-index

如何使用 jQuery 为文本对齐动态添加样式

一组元素中具有最大高度的元素

使用 JQuery 激活 bootstrap 选项卡

$(document).on("click"... 不工作?

jQuery 追加淡入

请求的资源错误中不存在Access-Control-Allow-Origin标头

textarea 的 val() 与 text()