Last active
November 6, 2020 01:01
-
-
Save pon-x/68cb32488ff00be4da77bc608520ae07 to your computer and use it in GitHub Desktop.
コピペボタンを実装する
This file contains 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
<html> | |
<body> | |
<input id="copy1" type="text" value="target1" readonly> | |
<button onclick="CopyClip(1)">コピー</button> | |
<p> | |
<input id="copy2" type="text" value="target2" readonly> | |
<button onclick="CopyClip(2)">コピー</button> | |
<script> | |
function CopyClip(id) { | |
var target = document.getElementById('copy' + id); | |
target.select(); | |
document.execCommand("Copy"); | |
alert("文字列「 " + target.value + "」をコピーしました。"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment