javaScript如何复制粘贴指定div中的内容,下面web建站小编带大家了解一下如何通过document.execCommand('copy')
来实现这个功能!
先引入sweetalert.min.css和sweetalert.min.js
复制粘贴实现代码如下:
function copyText(str_file) { const btn = document.querySelector('.'+str_file); var copy_val = document.getElementById(str_file) var copy_file = copy_val.getAttribute("href"); btn.addEventListener('click',() => { const input = document.createElement('input'); document.body.appendChild(input); input.setAttribute('value', copy_file); input.select(); if (document.execCommand('copy')) { document.execCommand('copy'); swal("复制成功!","success"); } document.body.removeChild(input); }) }
getElementsByclassName不兼容IE6/7/8解决方法!
标签: execCommand, querySelector, 复制粘贴
上面是“javaScript如何复制粘贴指定标签中的内容”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2738.html
workflows工作流
水中一台精致而破旧的老式电视鱼缸ComfyUI工作流
图生图局部重绘ComfyUI工作流
一只蓬松柔软的圆形半鳄梨玩偶
一个闪闪发光的金属球ComfyUI工作流
一位宇航员做在一只乌龟上在星空中游走
池塘边的大熊猫ComfyUI工作流
树上挂着一只表情可爱的香蕉ComfyUI工作流二
一个表情深思熟虑的成熟男人
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!