📜  jquery在html元素新行中下载文本 - Html代码示例

📅  最后修改于: 2022-03-11 14:52:52.932000             🧑  作者: Mango

代码示例1
function download() {
        var a = document.body.appendChild(
            document.createElement("a")
        );
        var textToWrite = document.getElementById("show-data").innerText;
        a.download = "export.txt"; 
        textToWrite = textToWrite.replace(/\n/g, "%0D%0A"); 
        a.href = "data:text/plain," + textToWrite;
        a.click();
    }