Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const copyToClipboard = (obj) => {
- event.preventDefault();
- const el = document.createElement("textarea");
- el.value = obj.dataset.url;
- el.setAttribute("readonly", "");
- el.style.position = "absolute";
- el.style.left = "-9999px";
- document.body.appendChild(el);
- const selected =
- document.getSelection().rangeCount > 0
- ? document.getSelection().getRangeAt(0)
- : false;
- el.select();
- document.execCommand("copy");
- console.log(event.target);
- let tooltip = event.target.querySelector("tooltiptext");
- console.log(tooltip);
- tooltip.innerHTML = "Copied: " + el.value;
- document.body.removeChild(el);
- if (selected) {
- document.getSelection().removeAllRanges();
- document.getSelection().addRange(selected);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement