Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@goldalworming
Last active May 13, 2019 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goldalworming/e646d7471d53ad3d0b93b81ff771c207 to your computer and use it in GitHub Desktop.
Save goldalworming/e646d7471d53ad3d0b93b81ff771c207 to your computer and use it in GitHub Desktop.
// 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