<a value="123" onclick='cop_text(123)' href='#<?echo $qq;?>'><?echo $qq;?></a>
function cop_text($zn) {
document.execCommand("copy");
alert("Скопировал текст: " + $zn);
}
navigator.clipboard.writeText("123")
function copyToClipboard(text) {
let span = document.createElement('span');
span.style.position = 'absolute';
span.style.top = 0;
span.style.zIndex = -999;
span.style.opacity = 0;
span.style.color = 'initial';
span.style.fontSize = 'initial';
span.style.whiteSpace = 'pre';
span.appendChild(
document.createTextNode(text)
);
document.body.appendChild(span);
let range = document.createRange();
let selection = window.getSelection();
selection.removeAllRanges();
range.selectNode(span);
selection.addRange(range);
let success;
try {
success = document.execCommand('copy');
} catch(e) {
success = false;
}
selection.removeAllRanges();
document.body.removeChild(span);
return success;
}