/* return content of input field to variable text */ var text = document.getElementById("text"); /* return button to variable btn */ var btn = document.getElementById("btn"); /* call function on button click */ btn.onclick = function() { text.select(); document.execCommand("copy"); }
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