How can I prevent selecting text in Google Chrome?

后端 未结 2 854
迷失自我
迷失自我 2021-02-05 09:51

Doesn\'t oEvent.preventDefault(); work in GC? I need to prevent selecting text when the onmove event is triggered.

EDIT: It turns out to be very easy...

2条回答
  •  失恋的感觉
    2021-02-05 09:58

    -webkit-user-select: none CSS style controls whether the user is allowed to select the
    text of the element.

    For completeness sake, this covers all supporting browsers (IE is not considered a web browser):

    .no-select
    {
       user-select: none;
       -o-user-select:none;
       -moz-user-select: none;
       -khtml-user-select: none;
       -webkit-user-select: none;
    }
    

    To do it through Javascript, just create a class and add the node's attributes.

提交回复
热议问题