Im trying to make it so when u click the button it copys the text, it has the command for it but its giving me errors and i dont know what to do. Im not sure if its becasue on w3schools they say to not use the command or something else
execCommand is a function of global object document not an object of element that's why you get error.
when you do
document.getElementById('cop'). execCommand ('copy') it just copy once means when you try to edit textbox then do copy then it won't copy edited text. It just show you previous copied text.
yes but whenever i use
document.getElementById(“cop”).execCommand(“copy”); it comes out as an error, but whenever i use document.getElementById(“cop”).select();
document.execCommand(“copy”); it works. why is that? Shouldnt they both perform the same task?
Solo That selects all text in textarea i just want it to copy what user wants. For example if i have Hello World! written in textarea and i only want Hello to be copied i would select it and press the button. idk how to do that and i tried multiple ways