Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var text = $("#discountCode").get(0); // Grab the node of the element
- var selection = window.getSelection(); // Get the Selection object
- var range = document.createRange(); // Create a new range
- range.selectNodeContents(text); // Select the content of the node from line 1
- selection.removeAllRanges(); // Delete any old ranges
- selection.addRange(range); // Add the range to selection
- document.execCommand('copy'); // Execute the command
Add Comment
Please, Sign In to add comment