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");

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
generate file and download file using jquery jquery dowload file download the file from url using jquery download file using url in jquery download file using link jquery Start downloading file using JQuery jquery cords download file download file jquery preview jQuery download file from url and save javascript jquery download file download file using javascript jquery download file using javascript/jquery read and download a file with jquery file download with jquery create file download with jquery jquery download file from server how to download file from path in jquery donwload file jquery download file with jquery download a file from location using jquery jquery download a file from url download file in jquery codepan download file in jquery jquery download file button jquery download file by url file downloader jquery write and download file jquery download a file in jquery jquery download file js jquery download file txt jquery http download file jquery download files how to implement download functionality in jquery download file from browser in jquery jquery download file from response jquery download file from button jquery download file on button click download file jquery file download using jquery download file by jquery download files with jqury jquery download file from anchor tag download file on button click in jquery jquery automatic download file jquery when file is downloaded jquery on downloaded file js download using jquery jQuery download file jquery download file from url download file using jquery
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source