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解决方法!
上面是“javaScript如何复制粘贴指定标签中的内容”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2738.html
workflows工作流
一个以破旧的怀旧史努比玩偶
爱因斯坦在做实验3d动漫ComfyUI工作流
一颗柔和的水晶金字塔ComfyUI工作流
一个全脸彩绘和纹身的超级名模ComfyUI工作流
池塘边的大熊猫ComfyUI工作流
森林里坐着一个外星人ComfyUI工作流
去掉背景(抠图)comfyui工作流
一只透明老虎骨骼标本ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

3D立体人物效果
js实现table表格动态新增行和列表
Bootstrap可视化拖放布局
css3绘制一个会动的大嘴鸟
利用CSS3做一个星级评分样式
黑客入侵效果代码







