分享一款子比主题独立下载页面美化!
JS代码
<!--下载页面密码复制-->
if(document.querySelectorAll(".but-download .badg")!=undefined){
const reg = /[a-zA-z0-9]/ig;
const copy = document.querySelectorAll(".but-download .badg");
for (let i = 0; i < copy.length; i++) {
copy[i].index = i;
copy[i].setAttribute("data-toggle", "tooltip");
copy[i].setAttribute("data-original-title", "点击复制");
copy[i].addEventListener("click", copyOperation);
};
function copyOperation() {
var oInput = document.createElement("input");
let text = this.innerText;
text = text.match(reg).join("");
oInput.value = text;
document.body.appendChild(oInput);
oInput.select();
document.execCommand("Copy");
oInput.className = "oInput";
oInput.style.display = "none";
this.setAttribute("data-original-title", "已复制");
};
};
这里再套个点击复制密码功能吧!
© 版权声明
THE END
暂无评论内容