copy selected text input javascript
HTML
<input type="text" id="url" value="https://jsfiddle.net/tttttt"/>
<a href="#" id="copy">copy</a>
JavaScript
document.getElementById("copy").onclick = function() {
document.querySelector('#url').select();
try {
var successful = document.execCommand('copy');
} catch(e) {}
document.querySelector('#url').blur();
return false;
}