I am trying to copy div element to clipboard in vuejs. I have gone through to search related solution and applied. But not working. I ant to copy full table to clipboard. Thanks in advance
<button v-on:click = "copyToClipboard(select_txt)">Click To Copy</button>
<table class="table table-sm" id="select_txt">
<tr>
<td>Name</td>
<td> abcd </td>
</tr>
<tr>
<td>Phone</td>
<td>124545</td>
</tr>
</table>
Methods
methods:{
copyToClipboard(containerid){
var range = document.createRange();
range.selectNode(containerid);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
window.getSelection().removeAllRanges();
alert("data copied");
}
},