Cannot copy text to clipboard

I want to copy some text that is written to the clipboard. I created the following function: function copyTextToClipboard(){ document.getElementById(“contactsInfo”).select(); document.getElementById(“contactsInfo”).setSelectionRange(0, 99999) document.execCommand(“copy”); } That is called when the user clicks on the element: document.getElementById(“contactsInfo”).addEventListener(“click”, ()=>{ copyTextToClipboard(); }) The element in HTML: <div class=”information-container”> <p id=”contactsInfo”>Email: allab.di@ubi.pt</p> <p id=”contactsInfo”>Phone: +310961810340</p> <p id=”contactsInfo”>Street: Bolama</p> </div> It…

Details