SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var copyTextareaBtn = document.querySelector(".click-to-copy");
  2.  
  3. copyTextareaBtn.addEventListener('click', function(event) {
  4.   var copyTextarea = document.querySelector('.click-to-copy-text');
  5.   copyTextarea.focus();
  6.   copyTextarea.select();
  7.  
  8.   try {
  9.     var successful = document.execCommand('copy');
  10.     var msg = successful ? 'successful' : 'unsuccessful';
  11.     console.log('Copying text command was ' + msg);
  12.   } catch (err) {
  13.     console.log('Oops, unable to copy');
  14.   }
  15. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top