JSFiddle - React, Tailwind, and code Playground
by Nimitt Shah
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<table>
<tr class="container"><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>
</table>
<button onclick="copyToClipboard('.container')">Copy container #s</button>
JavaScript
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
//Added below code;
var cellValues = $(element).find('td').map(function(){
return $(this).text();
}).get();
var allCellValues = cellValues.join(',');
//Added above code;
$temp.val(allCellValues).select();
document.execCommand("copy");
$temp.remove();
console.log(allCellValues);
}