How do I disable text selection with CSS or JavaScript?


I am making a HTML/CSS/jQuery gallery, with several pages.

I indeed have a “next” button, which is a simple link with a jQuery click listener.

The problem is that if the user click the button several times, the text of the button is selected, and then the full line of text. In my really darky design, that is really ugly and nonsensical.

So here is my question: Can you disable text selection on HTML?
If not, I’ll terribly miss flash and its high level of configuration on textfields…


 style="-moz-user-select: none; -webkit-user-select: none; -ms-user-select:none; user-select:none;-o-user-select:none;" 
 onselectstart="return false;" 
 onmousedown="return false;">

Answered By – Jerome

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published