Guest User

Untitled

a guest
Nov 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. var text = $("#discountCode").get(0); // Grab the node of the element
  2.  
  3. var selection = window.getSelection(); // Get the Selection object
  4.  
  5. var range = document.createRange(); // Create a new range
  6.  
  7. range.selectNodeContents(text); // Select the content of the node from line 1
  8.  
  9. selection.removeAllRanges(); // Delete any old ranges
  10.  
  11. selection.addRange(range); // Add the range to selection
  12.  
  13. document.execCommand('copy'); // Execute the command
Add Comment
Please, Sign In to add comment