How can I disable highlighting in html or JS?

后端 未结 7 1939
太阳男子
太阳男子 2020-12-13 19:24

I need to disable the highlighting of selected text on my web app. I have a good reason for doing this and know that this is generally a bad idea. But I need to do it anyway

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 20:02

    The CSS3 solution:

    user-select: none;
    -moz-user-select: none;
    

    There is also a webkit prefix for the user-select, but it makes some form fields impossible to focus (could be a temporary bug), so you could go with the following pseudo-class for webkit instead:

    element::selection
    

提交回复
热议问题