-
-
Save fundon/1369584 to your computer and use it in GitHub Desktop.
Enable/Disable text selection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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