Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Copy to clipboard

// Method 4 : Copying from input
<head>
  <script>
function copyToCliBoard() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  copyText.setSelectionRange(0, 99999); /* For mobile devices */
  document.execCommand("copy");
  alert("Copied the text: " + copyText.value);
}
</script>
</head>
<body>
<input type="text" value="Some Context" id="myInput">
<button onclick="copyToCliBoard()">Copy text</button>
</body>
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #Copy #clipboard
ADD COMMENT
Topic
Name
2+4 =