Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// dari https://codepen.io/PJCHENder/pen/jamJpj?editors=1010
// masukan html ini
// <input type="hidden" id="idcopy" :value="copyval">
// <button class="absolute cursor-pointer" style="right:10px;top:100px;" @click="copyvalue()">tes</button>
copyValue () {
let testingCodeToCopy = document.querySelector('#idcopy')
testingCodeToCopy.setAttribute('type', 'text')
testingCodeToCopy.select()
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
alert('Testing code was copied ' + msg);
} catch (err) {
alert('Oops, unable to copy');
}
/* unselect the range */
testingCodeToCopy.setAttribute('type', 'hidden')
window.getSelection().removeAllRanges()
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.