87,992
社区成员
发帖
与我相关
我的任务
分享
function selectTxt() {
if (document.selection) {
return document.selection.createRange().text;
} else {
return window.getSelection().toString();
}
}
在要实现的容器里绑一下mouseup事件,判断一下选中的文字是否为空,不为空则在鼠标的x轴、y轴的附近插入一个复制按钮,
设置按钮保存选中的内容保存的剪切板:document.execCommand("Copy");