编辑后带有JQuery或JavaScript的HTML源代码

编辑后带有JQuery或JavaScript的HTML源代码,javascript,html,Javascript,Html,我用它来捕获单个HTML页面的HTML源代码。 除了一件事,它工作得很好。 在我的html页面中输入值后,当我执行捕获时,它只捕获没有编辑值的页面 有什么想法吗 var getDocTypeAsString = function () { var node = document.doctype; return node ? "<!DOCTYPE " + node.name + (node.publicId ? ' PUBLIC "' + node.publi

我用它来捕获单个HTML页面的HTML源代码。 除了一件事,它工作得很好。 在我的html页面中输入值后,当我执行捕获时,它只捕获没有编辑值的页面

有什么想法吗

var getDocTypeAsString = function () {
    var node = document.doctype;
    return node ? "<!DOCTYPE "
    + node.name
    + (node.publicId ? ' PUBLIC "' + node.publicId + '"' : '')
    + (!node.publicId && node.systemId ? ' SYSTEM' : '')
    + (node.systemId ? ' "' + node.systemId + '"' : '')
    + '>\n' : '';
};




 function getPageHTML() {
     //    alert( "<html>" + $("html").html() + "</html>" );

     console.log(getDocTypeAsString() + document.documentElement.outerHTML);    
 }
var getDocTypeAsString=函数(){
var节点=document.doctype;

返回节点?”您想要实现什么

语句
document.documentElement.outerHTML
将以HTML本身作为呈现

输入元素的值在之后填充,因此通过
outerHTML
不可见

您可以运行元素,检查它们并填充DOM

最好的办法是描述你想要实现什么,并将完整的代码示例放在codepen或类似的工具上。

你不能这么做,这很简单。你从浏览器中看到的是“源代码”

使用jQuery或JS解析文档输入值


然后在你的getDocTypeAsString中重新输入它。我发现了一些似乎很好用的东西,但我不是一个根据可能的限制来判断这一点的专家

注意这样的物品

$( document ).ready(function() {
    var isDirty = false;
    $("textarea").on("change", function() {
        isDirty = (this.defaultValue !== this.value);
        if (isDirty)
            this.defaultValue = this.value;
    });

    $("input").on("change", function() {
        isDirty = (this.defaultValue !== this.value);
        if (isDirty)
            this.defaultValue = this.value;
    });
});
function getPageHTML() {
    console.log( "<html>" + $("html").html() + "</html>");
}
像这样调用新html的源代码

$( document ).ready(function() {
    var isDirty = false;
    $("textarea").on("change", function() {
        isDirty = (this.defaultValue !== this.value);
        if (isDirty)
            this.defaultValue = this.value;
    });

    $("input").on("change", function() {
        isDirty = (this.defaultValue !== this.value);
        if (isDirty)
            this.defaultValue = this.value;
    });
});
function getPageHTML() {
    console.log( "<html>" + $("html").html() + "</html>");
}
函数getPageHTML(){ log(“+$(“html”).html()+”); }
您在提供的代码中编辑值的位置?为什么不使用jquery时,jquery会出现在标记中?几分钟前,fiddlejs页面上有一条注释提供了解决方案。为什么删除了它?它使用了jquery,但可以在不使用jquery调用的情况下重写。好的,公平点。我想捕获完整且经过编辑的html页面,并将其另存为一个博客对不起