Skip to content

Instantly share code, notes, and snippets.

@aidilfbk
Created August 14, 2010 11:48
Show Gist options
  • Save aidilfbk/524228 to your computer and use it in GitHub Desktop.
Save aidilfbk/524228 to your computer and use it in GitHub Desktop.
jQuery plugin to prevent selection of text
// Usage: $("elements").disableSelection()
(function($){
$.fn.extend({
disableSelection : function() {
return this.each(function() {
this.onselectstart = function(){return false;};
this.unselectable = "on";
jQuery(this).css({'-moz-user-select': 'none', '-webkit-user-select': 'none', 'user-select': 'none');
});
}
});
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment