How can I disable highlighting in html or JS?

后端 未结 7 1950
太阳男子
太阳男子 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:06

    I think you're looking for the :focus pseudo class. Try this:

    input:focus {
      background-color: #f0f;
    }
    

    It will give your input a pretty purple/pink color when selected.

    I'm not sure which properties you have to (un)set, but I think you can find out yourself using trial and error.

    Also note that the highlighting or absence thereof is browser specific!

提交回复
热议问题