Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Copy (CTRL + C) com JavaScript
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<input id="text" />
<button id="copy">Copy</button>
<script type="text/javascript">
const textInput = document.getElementById('text');
const copyButton = document.getElementById('copy');
copyButton.addEventListener('click', ()=> {
textInput.select();
document.execCommand('copy');
});
</script>
</body>
</html>
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.