Skip to content

Instantly share code, notes, and snippets.

@jasich
Created January 29, 2018 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasich/bf6c9a21e649252a512780dc358ea9a9 to your computer and use it in GitHub Desktop.
Save jasich/bf6c9a21e649252a512780dc358ea9a9 to your computer and use it in GitHub Desktop.
Browser Copy in CLJS
(defn copy-text-from-elem
[elem-id]
(let [elem (.getElementById js/document elem-id)]
(.select elem)
(try
(if (.execCommand js/document "copy")
"Copied to Clipboard!!"
"Sorry Couldn't Copy")
(catch :default e
"Sorry Couldn't Copy"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment