1
I am putting a script to copy the link to clipboard using the plugin ZeroClipboard
. The problem is that I have a list with several links that comes from MySQL
. And in the loop of the list comes always the id
"copy-link" on <a>
. When I click the second link or the next ones, then it doesn’t copy to the clipboard, it’s just copying the first one. I think the problem is the ID is 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>
Did not solve, just copy the first link.
– Alisson Acioli