Javascript DOM CSS Style userSelect Property get

Introduction

Get the value of the "user-select" property of an element:

document.getElementById("demo").style.userSelect;

Click the button to get the value of the "user-select" property of the p element below.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<p id="demo" style="user-select:none">It is not possible to select this text.</p>

<p id="demo"></p>


<script>
function myFunction() {/* w ww  . j  a  va 2  s .c om*/
  document.getElementById("demo").innerHTML = document.getElementById("demo").style.userSelect;
}
</script>
</body>
</html>



PreviousNext

Related