有没有人知道这有没有触发器,或者我可以轮询来检查页面上当前是否有突出显示的变量?
发布于 2018-08-26 19:22:53
您可以检查是否触发了"mouseup"-event,然后获取当前选择的文本:
document.onmouseup = ()=>{
selection = window.getSelection().toString()
if(selection){
alert(`"${selection}" is highlighted`)
}
}
Select me!
https://stackoverflow.com/questions/52029471
复制相似问题