Detect what is selected (highlighted) or clicked within an element on a page?

空扰寡人 提交于 2019-12-06 10:31:36

window.getSelection() is what you need in all major browsers except IE < 9, which has a different API. window.getSelection() returns a Selection (spec) object from which you can extract a DOM Range (spec) representing the selection.

For IE < 9, you can look at document.selection, or use a library such as my own Rangy, which provides the same standards-based API in all major browsers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!