Does jquery or jquery-ui has such functionality? Disable text selection for given document element.
+2
A:
There is no such function built-in.
However, you can write a simple plugiin to do it for you:
$.fn.disableSelection = function() {
$(this).attr('unselectable', 'on')
.css('-moz-user-select', 'none')
.each(function() {
this.onselectstart = function() { return false; };
});
};
SLaks
2010-04-23 15:58:11
The JavaScript alternative works only for IE. "onselectstart" is not available for other browsers
Omar Abid
2010-04-23 16:32:37
@Omar: I'm well aware of that.
SLaks
2010-04-23 16:33:18
+1! I knew there was a simple way to do this. I have done this in Prototype in the past, but now that I am switching over to jQuery I was having trouble making the conversion. Thanks!
exoboy
2010-08-03 01:02:19