1

I want implement text button.

so user should click on it . but when user clicks twice there is selection markup all around the sentence. so I want prevent this behavior but because the area and the button text himself is just text i want make user able to select the text with mouse gesture like normal selection .

so, in short. How i prevent double click selection but not regular selection and to make the solution challenging how it can be done with CSS

pery mimon
  • 7,713
  • 6
  • 52
  • 57
  • Possible duplicate of [Prevent text selection after double click](https://stackoverflow.com/questions/880512/prevent-text-selection-after-double-click) – pery mimon May 21 '19 at 21:27

2 Answers2

0

Try to use onselectstart="return false" onmousedown="return false" properies. Something like this:

<input type="button" value="Button text" onselectstart="return false" onmousedown="return false" />
Anton Zikov
  • 144
  • 8
0

From other question https://stackoverflow.com/a/43321596/1919821

document.addEventListener('mousedown', function (event) {
  if (event.detail > 1) {
    event.preventDefault();
    // of course, you still do not know what you prevent here...
    // You could also check event.ctrlKey/event.shiftKey/event.altKey
    // to not prevent something useful.
  }
}, false);

//one line verstion
document.onmousedown = e => ((e.detail > 1)? (e.preventDefault():'')

pery mimon
  • 7,713
  • 6
  • 52
  • 57