jquery原生实现文本点击复制功能
jquery原生实现文本点击复制功能
<input class="copy_input" type="text" value="123" disabled> <button class="copy_button">复制</button> <input class="hide" type="text" >
<script> $(function () { // 点击复制 $(".copy_button").click(function () { var text = $(this).prev().val(); $(this).next().val(text); $(this).next().select(); document.execCommand("copy"); alert("复制成功"); }); }); </script>
本文属原创,转载请注明原文:http://www.zhimatong.com/jiaocheng/798.html
为保证教程的实用性及扩大知识面覆盖,如果您有相似问题而未解决,可联系在线客服免费技术支持。
内容有用
热门主题
相关阅读
- 苹果手机iOS设备,浏览器在 textarea 或 input 中输入文字时页面放大的解决办法
- select选择后直接跳转到其他网站的三种方式
- 详解CSS居中对齐的3种方式15个样例
- Echarts图表基本参数设置说明
- jQuery报错$(this).attr(‘checked‘)undefined/checkbox无法改变其状态的解决方法
- jq .html() 特效无效的解决办法
- 如何将iconfont中的字体图标全部展示在页面中
- HTML特殊字符符号大全
- jQuery清空input的值,清除标签内容的方法
- jQuery 获取相同 class元素的最后一个元素或id
- ajax传递data的三种传递方式
- jQuery跳转页面的3种代码示例