I have a input field with plus minus sign to raise/lower the number in it. Looks like this:
<a onclick="less()">-</a>
<input type="text" text-input">
<a onclick="more()">+</a>
How can I disable/prevent the select/highlight of the +/- text when I click to raise the numbers?
I'm looking for a solution that works cross browser. Thanks
To disable text selection highlighting in Google Chrome browser using CSS just set -user-select CSS property to none. And no prefix is required for Google Chrome and Opera Browsers.
You'll need to call event. preventDefault() in both the down and move events in order to keep the browser from selecting text. Save this answer.
To disable the text selection when the user double clicks on the HTML element, you can use the user-select property and set its value to none in CSS.
Depending of what versions of browsers you have to support, you can try using css property user-select
to none
. Here you have an example of such implementation http://css-tricks.com/almanac/properties/u/user-select/
you can use css ::selection
::selection {
background: none;
}
::-moz-selection {
background: none;
}
::-webkit-selection {
background: none;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With