Hello,
I want some text to be automatically copied to the clipboard when clicking on it. I followed what clipboardjs says on their website but I can’t recreate the behavior. My theme, CodeIT, uses clipboardjs.
This is how it’s supposed to work, according to clipboardjs.
A pretty common use case is to copy content from another element. You can do that by adding a
data-clipboard-target
attribute in your trigger element.
The value you include on this attribute needs to match another’s element selector.
<!-- Target -->
<input id="foo" value="https://github.com/zenorocha/clipboard.js.git">
<!-- Trigger -->
<button class="btn" data-clipboard-target="#foo">
<img src="assets/clippy.svg" alt="Copy to clipboard">
</button>
None of this works.
Would appreciate some help.