Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

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(/
/g, "%0D%0A"); 
        a.href = "data:text/plain," + textToWrite;
        a.click();
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jquery #download #text #html #element #line
ADD COMMENT
Topic
Name
2+1 =