JSFiddle - React, Tailwind, and code Playground
HTML
<script>
var copyClipboard = function (el) {
var htmlField, range, sel;
if (document.createRange && window.getSelection) {
htmlField = document.getElementById(el);
range = document.createRange();
sel = window.getSelection();
sel.removeAllRanges();
try {
range.selectNode(htmlField);
sel.addRange(range);
} catch (e) {
range.selectNode(htmlField);
sel.addRange(range);
}
document.execCommand("copy");
}
sel.removeAllRanges();
alert("Copied !");
}
</script>
<input type=button value="Copy to Clipboard" onClick="copyClipboard('boatrank')">
<div id="boatrank">
<table class="tableAuto">
<thead class="sticky">
<tr>
<th id="th_name">Skipper</th>
<th id="th_rank">Rank</th>
</tr>
</thead>
<tbody>
<tr class="hov">
<td class="colLeft">need eyes</td>
<td class="colRight">77</td>
</tr>
<tr class="hov">
<td class="colLeft">85 LE FENNEC</td>
<td class="colRight">129</td>
</tr>
<tr class="hov">
<td class="colLeft">bellenuit</td>
<td class="colRight">204</td>
</tr>
</tbody>
</table>
</div>