以下內容属于 ‘复制’ 便签:

点击按钮 复制input中的内容

点击按钮 复制input中的内容,也就是在input旁边加个按钮,把input的内容复制。 12345678910<input type="text" id="input" readonly value="点击按钮复制此文本!!"></input> <button onclick="onCopy()">复制内容</button>   <script>   function onCopy() {     document.getElementById('input').select()     document.execCommand('Copy')     document.getElementById('input').blur()   } </script> 这个代码我是在网上找的,参考的这个https://blog.csdn.net/ZGH_77733/article/details/126468057 但是在我的项目中有点问题,点击按钮虽然能复制但是会刷新页面…… 于是做了一个小更改如下。 12345678910<input type="text" id="inputid" readonly value="点击按钮复制此文本!!"></input> <input type="button" onclick="onCopy()" value="复制按钮">   <script>   function onCopy() {     document.getElementById('inputid').select()     document.execCommand('Copy')     document.getElementById('inputid').blur()   […] (more...)

点击按钮实现复制指定文本

特别是做资源站,有提取码之类的字段 还是挺管用。分享给大家。 复制文本框中的文字 HTML代码部分 1234<div>      <input type="text" value="The Text to Copy" id="copyMe">      <button onclick="copyMyText()">复制到剪贴板</button> </div> JavaScript 部分 12345678910<script> function copyMyText() {      //select the element with the id "copyMe", must be a text box      var textToCopy = document.getElementById("copyMe");      //select the text in the text box   […] (more...)