1

I've a situation where a user need to copy (click copy-to-clipboard icon) a link, however I've multiple dynamic links on a single page.

I've found the solution on the following post but I don't know a way to pass clicked icon ID to function as parameter and get the link copied to clipboard.

Click button copy to clipboard using jQuery

<a href="sourcefile.php"><i class="fa fa-link pull-right" id"copyToClipboard1"></i></a>
<a href="anotherfile.php"><i class="fa fa-link pull-right" id"copyToClipboard2"></i></a>
<a href="someimageURL"><i class="fa fa-link pull-right" id"copyToClipboard3"></i></a>

I went through the following post here in order to pass element ids to the function but no use as I just started crawling on jQuery path.

jQuery passing element ID into jquery statement?

Thanks in advance.

I don't have enough rep point therefore posting a new question [duplicate].

Community
  • 1
  • 1
  • I think this is not possible, you need to select the text before copy it. The text of your link is not selectable. [`document.execCommand('copy')`](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand) – R3tep Sep 21 '16 at 11:54
  • Hi, I see your point, If I add text in between anchor tags `code`sourcefile.php, will that be any use. thanks – Mohammed Moinuddin Waseem Sep 21 '16 at 12:24
  • 1
    Not sure, I think you need to put it into an input or maybe a div with contenteditable. – R3tep Sep 21 '16 at 12:28

0 Answers0