tags:

views:

1390

answers:

2

Hello,

I am trying to create a text button using simple span and formatting the text and providing onclick behavious. The problem is when a user clicks on the button, it sometimes highlights the text of the button.

I want to avoid such behaviour because it looks damn ugly when the text is selected. Any css/javascript/(jquery) i can use to avoid this?

Thank you very much for your time.

+5  A: 
spanid.onselectstart = function() {return false;} // ie
spanid.onmousedown = function() {return false;} // mozilla

First result on Google by the way...

extra

$('#spanid').selectstart(function(event) {
  event.preventDefault();
});
Ropstah
jQuery is also very nice: see post..
Ropstah
+1 for such a simple solution :) I didn't realize it would be this simple
Here Be Wolves
A: 

You can just write:

$('#spanid').disableSelection();
Elledan