<script>
function copyToClipboard()
{
var copyInput = document.createElement("input");
copyInput.setAttribute("value", document.getElementById("copyCode").value);
document.body.appendChild(copyInput);
copyInput.select();
document.execCommand("copy");
document.body.removeChild(copyInput);
}
</script>
<div class="input-group input-group-sm">
<input class="form-control" id="copyCode" value="copy this" type="text">
<div class="input-group-btn">
<button class="btn btn-primary btn-sm" type="button" onclick="copyToClipboard();">Copy this code</button>
</div>
</div>