DEV Community

Discussion on: Copy text to the clipboard with JavaScript in 10 lines of code

Collapse
 
albertomontalesi profile image
AlbertoM

You need to add it to the DOM so that you can then select its content. As I said, if the element you want to copy to clipboard is an input field you don't need to do that.