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); }
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); }
js copy string to clipboard
const el = document.createElement('textarea'); el.value = str; //str is your string to copy document.body.appendChild(el); el.select(); document.execCommand('copy'); // Copy command document.body.removeChild(el);
js copy to clipboard
function textToClipboard (text) { var dummy = document.createElement("textarea"); document.body.appendChild(dummy); dummy.value = text; dummy.select(); document.execCommand("copy"); document.body.removeChild(dummy); }
javascript copy to clipboard
const copyToClipboard = () => { navigator.permissions.query({name: "clipboard-write"}).then(result => { if (result.state == "granted" || result.state == "prompt") { // write to the clipboard now updateClipboard('I copy this string'); } }); }; const updateClipboard = (newClip) => { navigator.clipboard.writeText(newClip).then(() => { // clipboard successfully set console.log('success'); }, () => { // clipboard write failed console.log('Failed to copy'); }); }; const btn = document.getElementById('copy-button'); btn.addEventListener('click', copyHashtagToClipboard);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us