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

Prevent selection while dragging

高洛峰
Release: 2017-02-08 16:57:22
Original
1139 people have browsed it

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();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template