Q:

copy text to clipboard jquery

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

  function myFunction() {
  /* Get the text field */
  var copyText = document.getElementById("myInput");

  
  /* Select the text field */
  
  copyText.select(); 
  
  copyText.setSelectionRange(0, 99999); /*For mobile devices*/

  /* Copy the text inside the text field */
  document.execCommand("copy");

  
  /* Alert the copied text */
  
  alert("Copied the text: " + copyText.value);
} 
1

New to Communities?

Join the community