Skip to content

Instantly share code, notes, and snippets.

@farleyknight
Last active December 12, 2015 04:49
Show Gist options
  • Save farleyknight/4717425 to your computer and use it in GitHub Desktop.
Save farleyknight/4717425 to your computer and use it in GitHub Desktop.
(function($){
$.support.selectstart = "onselectstart" in document.createElement( "div" );
$.fn.disableSelection = function(){
return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
".disableSelection", function( event ) {
event.preventDefault();
});
};
$.fn.enableSelection = function(){
return this.unbind('.disableSelection');
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment