function copyToClipboard(){ var codeToBeCopied = document.getElementById('code-snippet').innerText; var emptyArea = document.createElement('TEXTAREA'); emptyArea.innerHTML = codeToBeCopied; const parentElement = document.getElementById('post-title'); parentElement.appendChild(emptyArea); emptyArea.select(); document.execCommand('copy'); parentElement.removeChild(emptyArea); M.toast({html: 'Code copied to clipboard'}) }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter