Dear Mates, Please click the ads to support us.

Copy Text to Clipboard JQuery

Kailash Singh

Copy Text to Clipboard JQuery

Published Oct 24,2021 by Kailash Singh

0 Comment     3650 Views    


In this tutorial, we are going to teach, how to create simple JQuery code to copy the text to the clipboard.

Here I make a simple button to copy the code.

 

Create text and Button

<h3 id="copy">I am copy this text</h3>
<button onclick="copyToClipboard('#copy')" class="btn btn-primary" title="Click to Copy">Copy</button>

In this button, we are creating a onclick function to copy the code.

 

JQuery code

You can create a function to copy the code.

<script type="text/javascript">
  function copyToClipboard(element) 
  {
    var $temp = $('<input>');
    $("body").append($temp);
    $temp.val($(element).text()).select();
    document.execCommand("copy");
    $temp.remove();
  }
</script>

 


Comments ( 0 )


SEARCH POST HERE


Support Us

Subscribe My YouTube Channel

Join Our Telegram Channel & Support Eachother

CATEGORIES

INTERVIEW QUESTIONS

PROJECT SOURCE CODE






POPULAR POSTS