codes:
const el = document.createElement('textarea');
document.body.appendChild(el);
el.value = 'copy text';
el.readOnly = true;
el.focus = true;
el.select();
const res = document.execCommand('copy')
if (res) {
alert('success')
} else {
alert('fail')
}