-
-
Save justforuse/6edd1cd96b64ae815e4af1992c8d99c2 to your computer and use it in GitHub Desktop.
JavaScript download canvas as image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const a = document.createElement('a'); | |
const ele = document.querySelector('canvas'); | |
a.download = 'img.png'; | |
a.addEventListener('click', () => { | |
a.href = ele?.toDataURL("image/png"); | |
}) | |
a.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment