【问题标题】:Add Html to Div with effect jQuery使用效果 jQuery 将 Html 添加到 Div
【发布时间】:2011-07-07 05:04:10
【问题描述】:

我想将加载的 html 从 Ajax 请求添加到 Div 并生效(例如向下滑动)。
我正在使用这段代码,但它还没有效果:

obj.html(msg.d).show('slow');

有可能吗?

更新:这是我的完整代码:

 $.ajax({
            type: "POST",
            url: options.webServiceName + "/" + options.renderUCMethod,
            data: options.ucMethodJsonParams,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: true,
            success:
                    function (msg) {
                       var html = msg.d;
                        obj.html(msg.d).show('slow');



                        // if specified make callback and pass element
                        if (options.completeHandler)
                            options.completeHandler(this);
                    },
            error:
                    function (XMLHttpRequest, textStatus, errorThrown) {
                        if (options.errorHandler) {
                            options.errorHandler(this);
                        } else {


                            obj.html("error");
                        }


                    }
        });

【问题讨论】:

标签: jquery jquery-effects


【解决方案1】:

应该可以——我假设 "obj" 是 a ,你可以尝试将它分成两部分,以确保你没有发生任何有趣的事情。

$(obj).html(msg.d); $(obj).show(500); // 500 ms animation time

【讨论】:

  • 谢谢。我的问题是 Div 没有隐藏。
【解决方案2】:

是的,你可以,但你的对象必须最初隐藏,所以这样做:

obj.hide().html(msg.d).show('slow');

希望这会有所帮助。干杯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-12
    • 1970-01-01
    • 2012-06-23
    相关资源
    最近更新 更多