Skip to content

Instantly share code, notes, and snippets.

@ten1seven
Created November 15, 2011 23:26
Show Gist options
  • Save ten1seven/1368732 to your computer and use it in GitHub Desktop.
Save ten1seven/1368732 to your computer and use it in GitHub Desktop.
Enable/Disable text selection
jQuery.fn.disableTextSelect = function() {
return this.each(function() {
$(this).css({
'MozUserSelect':'none',
'webkitUserSelect':'none'
}).attr('unselectable','on').bind('selectstart', function() {
return false;
});
});
};
jQuery.fn.enableTextSelect = function() {
return this.each(function() {
$(this).css({
'MozUserSelect':'',
'webkitUserSelect':''
}).attr('unselectable','off').unbind('selectstart');
});
};
@scottcioffi
Copy link

its GREAT, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment