1.html标签
<span id="copyUrl">文本</span>
<button id="btn" style="margin-left:10px;padding:5px;" type="button" >复制</button>'
2.js复制代码
$(document).on('click', "#btn", function () {
var Url2=document.getElementById("copyUrl").innerText;
const input = document.createElement("input");
input.readOnly = 'readonly';
input.value = Url2;
document.body.appendChild(input);
input.select();
input.setSelectionRange(0, input.value.length);
document.execCommand('Copy');
document.body.removeChild(input);
alert('复制推广链接成功');
});