JavaScript copy to clipboard not working
I have a function in my script that gives me an error. The function purpose is to copy text from static panel(not textbox or input) with onClick event. Uncaught TypeError: copyText.select is not a function The thing i want is to make the user able to click the text and it's get copied to his clipboard. Maybe you can offer better function that works? https://codepen.io/abooo/pen/jYMMMN?editors=1010 function myFunction() { var copyText = document.getElementById("display"); copyText.select(); document.execCommand("Copy"); alert("Copied the text: " + copyText.value); } From w3schools This will