I got a Website where a Invite-Link is displayed within <h2> tags
I simply want to copy the text to clipboard when the text itself is clicked.
my code looks like this:
<script> function CopyInviteLink() { var copyText = document.getElementById("invite-link"); copyText.select(); copyText.setSelectionRange(0, 99999) document.execCommand("copy"); } function setInviteLink(roomID) { const inviteLink = window.location.href + "/join.html?room=" + roomID; document.getElementById("invite-link").innerText = inviteLink; } </script> <h2 id="invite-link" onclick="myFunction()"></h2><br> I tried this method: https://www.w3schools.com/howto/howto_js_copy_clipboard.asp
which uses the following method: (document.execCommand("copy"))
but this does seem to only work with <input type="text">, but I would like to only have a clean text, not the "text input" style
could someone help me or link a solution?