Untitled
unknown
javascript
a year ago
433 B
16
Indexable
document.getElementById('download-btn').addEventListener('click', function() {
const image = document.getElementById('image-to-download');
const link = document.createElement('a');
// Set the download attribute and href to the image source
link.download = 'downloaded-image.jpg'; // The name for the downloaded file
link.href = image.src;
// Simulate a click on the link to trigger the download
link.click();
});
Editor is loading...
Leave a Comment