//html代码
客服微信:<input type="text" disabled="disabled" value="shaiyukefu" id='val' />
<button id='copy'>复制</button>
//js代码
$(function(){
$("#copy").click(function(){
var text=document.createElement('input');
text.id="webcopyinput";
text.value=$("#val").val();
text.style.position='fixed'
text.style.top="-10000px";
document.body.appendChild(text);
text.focus();
text.setSelectionRange(0,text.value.length);
copied=document.execCommand('Copy');
text.blur();
copied=false
})
})
jquery实现H5复制功能
最新推荐文章于 2023-06-27 11:13:49 发布