Last active
May 13, 2019 08:15
-
-
Save goldalworming/e646d7471d53ad3d0b93b81ff771c207 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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