When using ondblClick, we might not want to double click the selected text. We can use the following method:

Methods a

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

Method 2: CSS solution

Minor disadvantage: Directly disables the selected function

-moz-user-select: none; /* firefox */ -webkit-user-select: none; /*webkit */ -ms-user-select: none; /*IE10*/ -khtml-user-select: none; /* Early browser */ user-select: none;Copy the code