download file in jquery
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
// Start file download.
download("hello.txt","This is the content of my file");
Also in JavaScript:
- switch i javascript
- angular new component
- how to get seconds in timstamps js
- c# print object to json
- redux saga fetch api
- mongoose generate objectid
- import json file in react native
- html tag run only after whole page is loaded
- node command get to much time
- get hash js
- javascript replace spaces with dashes
- js form for website
- js settimeout mdn
- open bootstrap modal using javascript
- javascript function that make a choice
- jquery-3.5.1.min.js download
- javascript getdate
- how to make a modal stay center of screen
- javascript get element by multiple class
- webpack css not shoud be empty
- install node js in manjaro
- target all element besides the clicked one
- js get file name from path
- disable input jquery