Answers for "how to copy text to clipboard usng js"

56

javascript text to clipboard

function copyToClipboard(text) {
   const elem = document.createElement('textarea');
   elem.value = text;
   document.body.appendChild(elem);
   elem.select();
   document.execCommand('copy');
   document.body.removeChild(elem);
}
Posted by: Guest on March-20-2020
0

how to copyy a string variable to clipboard in js

var dummyContent = "this is to be copied to clipboard";
 var dummy = $('<input>').val(dummyContent).appendTo('body').select()
 document.execCommand('copy')
Posted by: Guest on January-30-2022

Code answers related to "how to copy text to clipboard usng js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language