Link to home
Create AccountLog in
Avatar of myyis
myyis

asked on

copy innerHLM of div using clipboardjs

Hi everybody,
I need to copy the content of the div to the desktop when clicked the div using https://clipboardjs.com/

<div id="id1" onclick="copy_content_to_clipboard(this);">
Textttttt
</div>

Anybody can help me?
Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of myyis
myyis

ASKER

Thank you very much for your quick answer. I have 2 questions:

1. How is it working for  "onclick" without an onclick script, if I want to make it onmouseover, what shall I do?

2.  At the examples here https://clipboardjs.com/ when you click the copy button you see a small confirmation pop-up. How can turn this on?
Hi,
1: thats because the constructor implements the onclick listener.
For an onmouseover you might track that event and fire a click event on the same element. But not sure if this makes sense (from an user perspective).

2: Because they implemented additionally a showTooltip function
showTooltip(e.trigger, 'Copied!');

Open in new window

but only on buttons with the class "btn".

HTH
Rainer