运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Change user-select with JavaScript</h1> <p>Click the "Try it" button to set the user-select property of the p element to "none":</p> <button onclick="myFunction()">Try it</button> <p id="demo">After you click on the button, it is not possible to select the text of this p element (try to double-click me before and after).</p> <script> function myFunction() { var x = document.getElementById("demo"); x.style.WebkitUserSelect = "none"; // Safari x.style.msUserSelect = "none"; // IE 10 and IE11 x.style.userSelect = "none"; // Standard syntax } </script> </body> </html>