In daily use, often encountered click button/menu when the text is selected, in order to avoid this situation, you can use the pure CSS to solve the problem (ie10+), for the old version can only use Js:onselectstart = ' return false; ' This way. Here's a look at-prefix-user-select:
Formal Syntax:none | Text | All | Element (-prefix-) User-select:none; All are not selectable (-prefix-) User-select:text; Allow text selection (-prefix-) User-select:all; In an HTML editor, if a double-click or Context-click occurred in sub-elements, the highest ancestor with this value wil L be selected. (-prefix-) user-select:element; Only IE FF support, ignoring ...
Note that this property does not belong to the standard!
Currently the main use is none & Text
The structure is assumed as follows:
<Body> <nav> <DT>Level 1</DT> </nav> <P>Xxxxxxxxxxxxxxxxxxxx</P></Body>
The CSS is as follows:
Body { -webkit-user-select: none;} nav dt{ -webkit-user-select: text;}
The result is: The text of the P tag cannot be selected, and the DT text will be selected normally.
CSS Block text selection