1. <div class="iddv" style="font-size: 12px;color: #333;position: absolute;bottom: 90px;width: 100%;">
    2. <div class="dv_top" style="font-size: 10px;
    3. width: 100%;
    4. box-sizing: border-box;
    5. color: #999;
    6. margin-bottom: 5px;">
    7. 可通过共读训练里的“训练营广场”页面搜索ID,找到训练营
    8. </div>
    9. <span>训练营ID:</span><span id="id_num">${obj.action.id}</span>
    10. <span class="copyId" style="margin-left: 15px;font-weight: 500;">复制</span>
    11. <input class="inp" style="display: none" type="button" onClick="copyUrl2()" value="点击复制代码" />
    12. </div>
    13. <div class="copy_suc" style="position: absolute;
    14. bottom: 110px;
    15. background: rgba(0, 0, 0, .43);
    16. padding: 5px 17px;
    17. font-size: 16px;
    18. color: #fff;
    19. border-radius: 10px;
    20. left: 50%;
    21. transform: translateX(-50%);
    22. display: none">
    23. 复制成功
    24. </div>
    1. // 复制
    2. function copyUrl2() {
    3. var Url2 = document.getElementById("id_num").innerText;// 要被复制的文本内容
    4. var oInput = document.createElement('input');
    5. oInput.value = Url2;
    6. document.body.appendChild(oInput);
    7. oInput.select(); // 选择对象
    8. document.execCommand("Copy"); // 执行浏览器复制命令
    9. oInput.className = 'oInput';
    10. oInput.style.display = 'none';
    11. document.body.removeChild(oInput);
    12. // alert('复制成功');
    13. // 复制成功之后的弹框(显示几秒)
    14. $(".copy_suc").show()
    15. setTimeout(function () {
    16. $(".copy_suc").hide()
    17. },1500)
    18. }
    19. // 点击复制触发复制文本
    20. $(".copyId").click(function () {
    21. $(".inp").click()
    22. })