所以我在这里有一种情况。卡是动态生成的。折扣优惠券仅在用户登录后显示。显示折扣优惠券后,
<div class='col-md-2' style='position: relative;height: 200px;'
id='showcode'>
<div class="geodir-category-options fl-wrap"style='position:
absolute;bottom: 0;' >
<div class="listing-rating card-popup-rainingvis">
<a class="trs-btn1 pointer" onmouseover='mover(this.id)'
onclick="checkSignIn("+i+");" id="+"btn".concat(i.toString())
style="margin-top: 0px" >Show discount code</a>
</div>
</div>
</div>
在折扣代码上单击它应该将文本复制到剪贴板。
答案 0 :(得分:0)
您可以使用select()
方法和execCommand()
来在元素内复制文本。
var txt = document.querySelector("ELEMENT_T0_BE_COPIED");
//selecting the text inside the element.
txt.select();
//copying content in to the clipboard
document.execCommand("copy");
//store the clipboard value in a variable.
var clipVal = txt.value;
您可以了解更多here