How to use 'css disable selection' in JavaScript

Every line of 'css disable selection' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
49function disableSelect(chkbox) {
50 var sibling = chkbox;
51 while (sibling != null) {
52 if (sibling.nodeType == 1 && sibling.tagName.toLowerCase() == "select") {
53 $(sibling).prop('disabled', !chkbox.checked);
54 }
55 sibling = sibling.previousSibling;
56 }
57}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

23export function removeUserSelectStyles(doc) {
24 try {
25 if (doc && doc.body) removeClassName(doc.body, 'react-draggable-transparent-selection');
26 if (doc.selection) {
27 doc.selection.empty();
28 } else {
29 window.getSelection().removeAllRanges(); // remove selection caused by scroll
30 }
31 } catch (e) {
32 // probably IE
33 }
34}

Related snippets