Home  >  Article  >  Web Front-end  >  Get the type of selected object in javascript_javascript skills

Get the type of selected object in javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:16:001279browse

In Javascript, textRange can be created using document.selection. But in fact, it cannot be created at any time.
We can use document.selection.type to determine whether the currently selected text or object is selected.

document.selection.type returns three values ​​"None" "Text" "Control"

Only when the return value is Text, the created textRange is valid.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn