Действия

Widget

Скопировать текст

Материал из ВикиВоины

0.00
(0 голосов)

<button class="button text-copy-button" onclick="copyText()">Скопировать текст</button> <script> function copyText() {

   var textToCopy = document.getElementById("text-copy").innerText;
   navigator.clipboard.writeText(textToCopy)
       .then(() => {
           alert("Текст скопирован!");
       })
       .catch(err => {
           console.error('Ошибка копирования: ', err);
       });

} </script>