【问题标题】:alert($(document).html();) [duplicate]警报($(文档).html();)[重复]
【发布时间】:2013-04-13 07:05:58
【问题描述】:

我有一个启用了 jquery 的 html 页面。

一旦用户使用 jquery 交互修改了页面,我需要保存生成的 DOM。

根据 [Get Jquery DOM][1], $(document).html();应该给我html,所以我试图提醒

$(document).html();

但是我收到警报未定义元素

http://jsfiddle.net/ujYzM/3/

请有人帮忙

提前致谢。

【问题讨论】:

  • 需要跟进的哥们!!!

标签: jquery html


【解决方案1】:

您可能希望使用 $('html')$('body') 获取 DOM

jsFiddle

alert($('html').html());
alert($('body').html());

【讨论】:

  • 我使用了 alert($('html').html());
【解决方案2】:

这应该可以工作

$(document).ready(function () {
     $("#sketch_board").droppable({
        hoverClass: 'smbrd',
        tollerance: "touch",
        drop: function (event, ui) {
            $("#sketch_board").append($('#div_drag').html());
            var x = $('#sketch_board').text();
            alert(x);
        }
    });

    $('#div_drag').draggable({
        containment: "window",
        revert: true
    });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-10
    • 2016-08-11
    • 2016-05-28
    相关资源
    最近更新 更多