<button class="trigger" data-text="Hello">Скопировать</button>
const button = document.querySelector(".trigger");
const dataText = button.dataset.text.trim();
button.addEventListener('click', e => {
if(!dataText.length) return;
navigator.clipboard.writeText(dataText)
.then(() => console.log("Done!"))
.catch(err => console.error(err))
})