I have a table in my web page. i write a code to copy td text to clipboard with a button. when i click the button td text copied to clipboard with break lines. how can i copy td text without break lines?
Html code:
<table>
<tr role="row">
<th style="padding-right: 8px;">copy</th>
<th style="padding-right: 8px;">phone</th>
<tr/>
<?php foreach ($all as $all_items) {?>
<tr>
<td>
<button class="btn-copy" type="button" >copy</button>
</td>
<td>
<?php if (isset($all_items['phone'])) echo $all_items['phone']; ?>
</td>
<tr/>
<?php } ?>
</table>
my javascript code:
$(".btn-copy").click(function() {
let tmpElement = $('<textarea style="opacity:0;"></textarea>');
let parent = $(this).closest('td').siblings().not(':last').each(function(){
tmpElement.text(tmpElement.text() + $(this).text() + '\t');
});
tmpElement.appendTo($('body')).focus().select();
document.execCommand("copy");
tmpElement.remove();
});