// 监听双击事件
document.addEventListener("dblclick", doubleClick, true);
// 监听释放鼠标按钮事件
document.addEventListener("doubleClick", mouseUp, true);
// 双击处理函数
function doubleClick() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
if ("" != text) {
console.log(text);
}
}
js获取 双击或者鼠标拖动选中文字
最新推荐文章于 2025-02-28 15:40:48 发布