点击按钮,复制文本
$('body').on('tap', '.copy-btn', function (e) {
e.preventDefault();
e.stopPropagation();
const range = document.createRange();
range.selectNode($(this).prev('.text')[0]);
const selection = window.getSelection();
if (selection.rangeCount > 0) {
selection.removeAllRanges();
}
selection.addRange(range);
document.execCommand('copy');
alert('文本已复制!');
});