Skip to content

Instantly share code, notes, and snippets.

Embed
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
clone.click(); // trigger the download
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.