Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop text from being selected?

In my web app the user can sometimes click the same button a number of times, skipping through messages and things, causing the </a> to be selected.

So how can I prevent this using Javascript (jQuery)

like image 899
Ben Shelock Avatar asked Aug 12 '10 16:08

Ben Shelock


People also ask

How do I turn off text selection?

You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.

How can I prevent text element selection with cursor drag?

Try applying user-select: none to an element and dragging over it.


1 Answers

You dont need script for this, here is the css:

-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
like image 186
Blowsie Avatar answered Sep 21 '22 21:09

Blowsie