Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Download all link's target files for the given selector
let linkSelector = '.download-button';
document.querySelectorAll(linkSelector).forEach(function(link) {
let clone = link.cloneNode(); // avoid existing event listeners
clone.setAttribute('download', ''); // indicate the download action; // trigger the download
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment