I'm putting a script to copy the link to clipboard, using the ZeroClipboard
plugin. The problem is that I have a list with multiple links that comes from MySQL
. And in the list loop always comes the id
"copy-link" in <a>
. When I click on the second or next link, then it does not copy to the clipboard, it is only copying the first one. I think the problem is ID because it's the same.
javascript
<script type="text/javascript">
// main.js
var client = new ZeroClipboard( document.getElementById("copy-link") );
client.on( "ready", function( readyEvent ) {
// alert( "ZeroClipboard SWF is ready!" );
client.on( "aftercopy", function( event ) {
// 'this' === 'client'
// 'event.target' === the element that was clicked
alert('Link copiado!');
} );
} );
</script>
html
<a href="javascript:void(0);" id="copy-link" data-clipboard-text="AQUI VAI O LINK">Copiar Link</a>