You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
720 B
JavaScript
28 lines
720 B
JavaScript
function copyToClipboard(elementId) {
|
|
|
|
/* Get the text field */
|
|
var copyText = document.getElementById(elementId);
|
|
|
|
/* Select the text field */
|
|
copyText = copyText.textContent;
|
|
|
|
/* Copy the text inside the text field */
|
|
navigator.clipboard.writeText(copyText);
|
|
|
|
var tooltip = document.getElementById("myTooltip");
|
|
tooltip.innerHTML = "Copied";
|
|
|
|
}
|
|
|
|
function resetCopy() {
|
|
|
|
var tooltip = document.getElementById("myTooltip");
|
|
tooltip.innerHTML = "Copy to clipboard";
|
|
|
|
}
|
|
|
|
//const clipboard = querySelector('.tooltiptext');
|
|
const minecraft = document.getElementById('minecraft-clip');
|
|
minecraft.addEventListener('click', copyToClipboard('minecraft-server'));
|
|
minecraft.addEventListener('mouseout', resetCopy());
|