-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How could we copy a component's text to the clipboard with HTMX? #531
Comments
Since you were asking for HTMX:
This makes sure not to copy "Copied" to the clipboard when the text was replaced. |
Just in case you were wondering how to do this in hyperscript (as this is the hyperscript repo), you can see an example on the hyperscript homepage with the CDN link. <div>
<code style="border: 2px dotted #00000055; margin: 0 10px; padding: 4px 6px; border-radius: 4px"><script src="https://unpkg.com/[email protected]"></script></code>
<button style="font:inherit;font-size:.8em;background:#3465a4;color:white;border:none;padding: 0 .4em; border-radius: .4em" _="on click
writeText(my previousElementSibling's innerText) on navigator.clipboard
put 'copied!' into me
wait 1s
put 'copy' into me">copy</button>
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have two large text fields and it would be really cool to have an HTMX button to copy the contents to the clipboard.
I can do this in vanilla JS but was wondering if there is some clever way to do this using inline HTMX.
Any suggestions?
Thanks.
The text was updated successfully, but these errors were encountered: