Created
October 9, 2015 06:41
-
-
Save JohnnyMa/6900f96a9e17253a0747 to your computer and use it in GitHub Desktop.
A modern approach to copy text to clipboard, pure js.
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
<!doctype html> | |
<html> | |
<head> | |
<title>test copy</title> | |
<script src="clipboard.min.js"></script> | |
</head> | |
<body> | |
<!-- Target --> | |
<input id="foo" value="test text... text"> | |
<!-- Trigger --> | |
<button class="btn" data-clipboard-target="#foo"> | |
<img src="assets/clippy.svg" alt="Copy to clipboard"> | |
</button> | |
<!-- repo: https://github.com/zenorocha/clipboard.js --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment