I have an element with text in it and in between text there are span
elements. When I highlight the parts of the text with the span
elements in it, it shows those elements text.
I looked for a solution and found the following css values, these should disable highlight and by the look of it, it does, but in code the values are still there.
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
-o-user-select: none;
user-select: none; /* Non-prefixed version, currently
supported by Chrome, Edge, Opera and Firefox */
In code I am getting the highlighted text like this window.getSelection().toString()
.
I cant find any other way to disable highlighting and dont understand why these css values dont work. What am I doing wrong? What other ways are there to disable highlight?