cssjs-func-lib/copy-to-clipboard.js
2023-10-29 22:14:25 +01:00

29 lines
779 B
JavaScript

function copyToClipboard(id) {
var copyText = document.getElementById(id);
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /*For mobile devices*/
/* Copy the text inside the text field */
document.execCommand("copy");
}
function copyDivToClipboard(id) {
let range = document.createRange();
range.selectNode(document.getElementById(id));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
window.getSelection().removeAllRanges();
}
function copiedToClipboard(id) {
var tooltip = document.getElementById(id);
tooltip.innerHTML = "Kopiert";
}
function resetClipboard(id) {
var tooltip = document.getElementById(id);
tooltip.innerHTML = "Kopieren";
}