Created
July 7, 2012 11:36
-
-
Save html/3065998 to your computer and use it in GitHub Desktop.
Enable/disable selection in jQuery
This file contains 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
// Stolen from jquery-ui and customized | |
(function($){ | |
$.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