Answers for "jquery download text in html element new line"

0

jquery download text in html element new line

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();
    }
Posted by: Guest on February-12-2021

Browse Popular Code Answers by Language