Quick way to copy custom text to clipboard using Jquery

Quick way to copy custom text to clipboard using Jquery
2 votes, 5.00 avg. rating (96% score)

Introduction

Very quick and simple code snippet with jquery to copy text to clipboard. Call the method and you can paste the text. This will be custom way of sending text to clipboard

Copy text to clipboard

function copyToClipboard(valuetocopy) 
{
	var $tempInput = $("<input>");
	$("body").append($tempInput);
	$tempInput.val(valuetocopy).select(); //select the text
	document.execCommand("copy"); //this will trigger the copy that is selected in above line
	$tempInput.remove(); //remove the temporary input
}

October 16, 2015 В· Adi В· No Comments
Posted in: Asp.Net, Sharepoint 2010, SharePoint 2013

Leave a Reply

What is 9 + 4 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)