Copy Text using jquery
<div id='selector'>
Hello this is copy text
</div>
<button class="copyBtn">Copy</button>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js">]
</script>
<script>
$(document).on("click",".copyBtn",function(){
var mytext= $("#selector").text();
var $temp = $("<input>");
$("body").append($temp);
$temp.val(mytext).select();
document.execCommand("copy");
$temp.remove();
});
</script>
Comments
Post a Comment
If you any doubt of any topic then you can comment me.