Copy Text to Clipboard JQuery Share
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>





Click to Join









Comments 0