Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to copy text in the clipboard in js

<html>
  <input type="text" value="Hello world"(Can be of your choice) id="myInput"(id is the name of the text, you can change it later)
<button onclick="Hello()">Copy Text</button>

<script>
  function Hello() {
  var copyText = document.getElementById('myInput')
  copyText.select();
  document.execCommand('copy')
  console.log('Copied Text')
}
</script>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #copy #text #clipboard #js
ADD COMMENT
Topic
Name
6+5 =