-2

I have a code like this:

<button onmousedown="alert('Hi!');">Some text</button>

But when I try to long click it (that’s why I put onMouseDownevent), my text is selected instead of only execute my script. How can I prevent my text from being selected when trying to execute onMouseDown event?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122

1 Answers1

0

You can use user-select: none property for that . So text is not selected by user