Home >Web Front-end >JS Tutorial >Prevent selection while dragging

Prevent selection while dragging

高洛峰
高洛峰Original
2017-02-08 16:57:221149browse

Sometimes when dragging, it will affect the dragging due to being selected, or cause some bugs. But use the following code to prevent it from being selected.

window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();

The above is the entire content of this article. I hope that the content of this article can bring some help to everyone's study or work. I also hope to support the PHP Chinese website!

For more related articles on preventing selection when dragging, please pay attention to the PHP Chinese website!

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