×
×
Copy Text to Clipboard JQuery
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 )
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date
Copyright 2018 - 2024 Elevenstech Web Tutorials All rights reserved.