Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

copy text to clipboard javascript

<script>
function copyToClipboard(element) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();
}
</script>

<p id="text">Hello</p>
<button onclick="copyToClipboard('#text')"></button>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #copy #text #clipboard #javascript
ADD COMMENT
Topic
Name
3+1 =