Copy link of an anchor tag to clipboard when clicking on it

try below code snippet

$('.copy_text').click(function (e) {
   e.preventDefault();
   var copyText = $(this).attr('href');

   document.addEventListener('copy', function(e) {
      e.clipboardData.setData('text/plain', copyText);
      e.preventDefault();
   }, true);

   document.execCommand('copy');  
   console.log('copied text : ', copyText);
   alert('copied text: ' + copyText); 
 });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

 <a class="copy_text"  data-toggle="tooltip" title="Copy to Clipboard" href="home/company_profile_detail">Copy Link</a>

Tags:

Jquery