Created
June 24, 2013 07:22
-
-
Save Wynout/5848292 to your computer and use it in GitHub Desktop.
jQuery Plugin disableSelection
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
/** | |
* jQuery Plugin disableSelection | |
* Disable selection of text content within the set of matched elements. | |
* | |
* @return {Object} jQuery | |
* @chainable | |
*/ | |
(function ($, window, document, undefined){ | |
$.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