<a title="<?= $u['did']; ?>" id="article">
<div class="td-text" id="copy-text"><?= $u['did']; ?></div>
</a>
$(document).on('click', '#article', function() {
const range = document.createRange();
range.selectNode($(this)[0]);//点击选择的文本
const selection = window.getSelection();
if (selection.rangeCount > 0) selection.removeAllRanges();
selection.addRange(range);
document.execCommand('copy');
});
标签:selection,const,点击,jq,range,文本,document
From: https://www.cnblogs.com/czjjy/p/16802615.html