Skip to content

Instantly share code, notes, and snippets.

@fundon
Forked from ten1seven/jquery.disableSelect.js
Created November 16, 2011 08:35
Show Gist options
  • Save fundon/1369584 to your computer and use it in GitHub Desktop.
Save fundon/1369584 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');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment