Для этого можно использовать jQuery. Метод execCommand()
выполняет указанную команду для выбранной части редактируемого раздела.
jQuery
$("button").click(function(){
$("textarea").select();
document.execCommand('copy');
});
JavaScript
document.querySelector("button").onclick = function(){
document.querySelector("textarea").select();
document.execCommand('copy');
};
<textarea>Copy my this ya</textarea>
<br>
<button>Select</button>