DEV Community

Bret
Bret

Posted on

how do you onClick, COPY text? (im making a app)

how do you "copy" the text that's within a class or id?
I want to build a app, that I can add custom snippets to, that I can just click a button... to copy... the snippet to paste.

what would that look like?

Top comments (3)

Collapse
 
juneikerc profile image
Juneiker

there are different ways to do that, personally I use navitagor.clipboard but you can also use Document.execCommand.

developer.mozilla.org/en-US/docs/W...
30secondsofcode.org/blog/s/copy-te...

Collapse
 
rishitkhandelwal profile image
Rishit Khandelwal • Edited

Well, navigator.clipboard ig?

Some comments may only be visible to logged-in visitors. Sign in to view all comments.