<inputtype="text"id="mytxt1"value="点击右侧复制按钮复制"class="n1input"></div><divstyle="width:48px;height:36px;position:absolute;margin-left:232px;*m
给按钮添加一个单击属性<buttononclick="copy">点我复制P里面的内容</button>比如要复制的是p标签的文字<pid="p">123</p><pid="p2">456</p><!DOCTYPEhtml><html><
利用浏览器中的开发者工具,就可以从查看html的源代码,从源代码中复制,就可以实现复制html的文字了。
/1、网页代码如下:<scriptlanguage=javascript>//自动COPY代码开始functionMM_findObj(n,d){//v4.0varp,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length...
alert("复制成功!");}</script><br/><br/>点击文本框时,复制文本框里面的内容<inputonclick="oCopy(this)"value="你好.要copy的内容!"><scriptlanguage="javascript">f
ie=edge"><title>Document</title></head><body><button>按钮</button></body><script>document.querySelector("button").onclick=({target})=>
functioncopyToClipBoard(id){//varbankName=document.getElementById("yh"+id).innerHTML;varaccount=document.getElementById("span"+id).innerHTML;account=account.replace("",&q
e.preventDefault();document.oncopy=null;}})(d);document.execCommand("Copy");}}</script><buttononclick="copyToClipboard('source1');">拷贝</button><inputty
functioncopy(obj){window.clipboardData.setData("text",obj.innerText)}</script><style>.a{cursor:hand;}</style><divonclick=copy(this)class=atitle="点击复制">11111
完整代码如下:<html><head><title>MyHtml.html</title><scripttype="text/javascript">functioncontentCopy(){//获取到对象varobj=document.getElementById("contentId");//