Скопировать текст: различия между версиями
Материал из ВикиВоины
Строка 4: | Строка 4: | ||
var textToCopy = document.getElementById("text-copy").innerText; | var textToCopy = document.getElementById("text-copy").innerText; | ||
navigator.clipboard.writeText(textToCopy) | navigator.clipboard.writeText(textToCopy) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
</script> | </script> |
Версия 15:00, 8 мая 2024
<button class="button text-copy-button" onclick="copyText()">Скопировать текст</button> <script> function copyText() {
var textToCopy = document.getElementById("text-copy").innerText; navigator.clipboard.writeText(textToCopy)
} </script>